Thanks for the quick posts.

Stupid me, I thought getInitParameter would always be for init-params.

I wonder why...
getServletContext.getInitParameter(String):String
is not
getServletContext.getContextParameter(String):String ?

not that it matters.

Thanks again.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Jason Coward
Sent: Saturday, May 12, 2001 1:46 PM
To: Orion-Interest
Subject: RE: init params


Russ:

The first two methods...

 * getInitParameter(String):String
 * config.getInitParameter(String):String

both reference the ServletConfig.getInitParameter(String):String method.  This
returns configuration information specified by an <init-param> element within a
<servlet> definition.

The other method...

 * getServletContext.getInitParameter(String):String

references ServletContext.getInitParameter(String):String. which retrieves
parameter values from the <context-param> element of a <web-app> definition.

Check out the Servlet API JavaDocs or specification docs for more info.

Jason Coward
Technical Relationship Manager
Mongoose Technology, Incorporated

| -----Original Message-----
| From: [EMAIL PROTECTED]
| [mailto:[EMAIL PROTECTED]]On Behalf Of Russ White
| Sent: Saturday, May 12, 2001 9:08 AM
| To: Orion-Interest
| 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