You have given init parameter to the servlet thats the reason your first two
statements given correct result.  The thrird one looks for the context
parameter which you haven't set.  Refer the difference between the
ServletInitParameter and the Context-Parameter.

For contextparameter you have give

<context-param>
    <param-name>contextP</param-name>
    <param-value>ContextValue</param-value>
</context-param>
----- Original Message -----
From: "Russ White" <[EMAIL PROTECTED]>
To: "Orion-Interest" <[EMAIL PROTECTED]>
Sent: Saturday, May 12, 2001 7:08 AM
Subject: init params


> Found something unexpected.
>
> I have attached an ear to illustrate.
>
> In the servlet TestServlet (config provided for expediency).
> <servlet>
> <servlet-name>test</servlet-name>
> <display-name>test</display-name>
> <servlet-class>com.sequenet.mvc.TestServlet</servlet-class>
> <init-param>
> <param-name>config</param-name>
> <param-value>test</param-value>
> </init-param>
> <load-on-startup>1</load-on-startup>
> </servlet>
> I try to get an init-param three ways.
>
>     System.err.println("param="+getInitParameter("config"));
>     System.err.println("param="+config.getInitParameter("config"));
>
System.err.println("param="+getServletContext().getInitParameter("config"));
>
> the first two print "test" as they should.
> the last one print "null".
>
> why?
>
> Just for kicks I performed this test in both the init() method and a
service()
> method.
>
> Any thoughts?
>
> WR
> Russ White
>
>
>

Reply via email to