-
Initialize Java servlet
I wonder how the initial parameters in Java servlet from? I mean,I used getInitialNames()
in my program,but the result is empty,so how to initialze the parameters
such as user,port...so on? I used an Init() method,still no success.
By the way,is there any mailling list for Java servlet? THank you.
-
Re: Initialize Java servlet
Do you mean getInitParameterNames()? Your servlet engine should have an
administration panel where you can configure servlets. One of the options
for a configured servlet is initialization parameters. Check the
documentation for your servlet engine.
PC2
H Ma <mahuiyuan@yahoo.com> wrote in message news:3a69b0d2$1@news.devx.com...
>
> I wonder how the initial parameters in Java servlet from? I mean,I used
getInitialNames()
> in my program,but the result is empty,so how to initialze the parameters
> such as user,port...so on? I used an Init() method,still no success.
> By the way,is there any mailling list for Java servlet? THank you.
-
Re: Initialize Java servlet
If you read Servlet Spec2.3 or 2.2, it specifies a concept called war file
and web.xml files. Typically web.xml should contain all information regarding
the setup of your servlets. Any servlet engine which supports servlet2.2
onwards should implement the concept of web.xml and war files. A typical
web.xml should look like this.
<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<servlet>
<servlet-name>InitialServlet</servlet-name>
<servlet-class>IntialServlet</servlet-class>
<init-param>
<param-name>Name1</param-name>
<param-value>Value1</param-value>
<load-on-startup>1</load-on-startup>
</servlet>
<welcome-file-list>
<welcome-file>default.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
</web-app>
What ever param names and values you specify for the servlet you can access
them from the servlet code.
"H Ma" <mahuiyuan@yahoo.com> wrote:
>
>I wonder how the initial parameters in Java servlet from? I mean,I used
getInitialNames()
>in my program,but the result is empty,so how to initialze the parameters
>such as user,port...so on? I used an Init() method,still no success.
>By the way,is there any mailling list for Java servlet? THank you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks