Initialize Java servlet


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Initialize Java servlet

  1. #1
    H Ma Guest

    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.

  2. #2
    Paul Clapham Guest

    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.




  3. #3
    Ruchi Dhar Guest

    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center