Hi Marek,
> -----Original Message-----
> From: Marek [SMTP:mdolgos@north-pacific.com]
> Sent: Thursday, September 21, 2000 1:47 AM
> To: tomcat-user@jakarta.apache.org
> Subject: getInitParameter()
>
> I need to read the value of an <init-param> from a servlets web.xml
> file. When I attempt to get the value via getInitParameter("paramName")
> it returns null. I have checked and double checked to make sure I am
> using the right name and that it does exist in web.xml. Can anyone think
> what the problem could be ? It seems like this should be a simple thing
> to accomplish.
>
> The web.xml file is as follows:
>
> <web-app>
> <display-name>Form Processor</display-name>
>
> <servlet>
> <servlet-name>formprocessor</servlet-name>
> <servlet-class>FormProcessor</servlet-class>
>
> <init-param>
> <param-name>MLIST</param-name>
> <param-value>g900</param-value>
> </init-param>
> </servlet>
>
> <servlet>
> <servlet-name>testprocessor</servlet-name>
> <servlet-class>TestProcessor</servlet-class>
> </servlet>
> </web-app>
>
> Marek
[Kitching Simon]
We use the same approach, and it works fine (tomcat 3.1, HPUX,
jdk1.2.2).
All that I can think of is that perhaps you are calling
context.getInitParam(..) instead of config.getInitParam,
but that's unlikely too as the servlet init method is passed
the ServletConfig.
My web.xml file is almost identical to yours, and the code is:
public void init(ServletConfig config) throws ServletException {
super.init(config);
Enumeration eLocalNames = config.getInitParameterNames();
while (eLocalNames.hasMoreElements())
{
String name = (String) eLocalNames.nextElement();
try
{
String value = (String) config.getInitParameter(name);
.....
|