Here are the observed behavior which is important for anyone who is trying to work around this bug, and for anyone who is trying to resolve this bug:
 
getServletConfig().getInitParameter(String name);
- Does not work ... always returns null.
 
getServletConfig().getServletContext().getInitParameter(String name);
- Will work, but ONLY if you put your parameter in the <context-param> </context-param> as shown below.
If the value is in the <init-param> </init-param> tags (see below) it will NOT work.
 
Thank you,
Jason B.
 
-----Original Message-----
From: Paul Hoepfner-Homme <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Thursday, October 26, 2000 1:00 PM
Subject: Re: Frustration with getInitParameter

Sorry, typo in web.xml below.  I had <servlet-param>MyServlet</servlet-param> before, but it should be <servlet-class> obviously.  I have fixed it below.
Finally, I'm not alone!!  I have 3.2 beta 6 as well.  Here is a how I have web.xml set up:

<web-app>
    <context-param>
        <param-name>test1</param-name>
        <param-value>here1</param-value>
    </context-param>
    <servlet>
        <servlet-name>myservlet</servlet-name>
        <servlet-class>MyServlet</servlet-class>
        <init-param>
            <param-name>test2</param-name>
            <param-value>here2</param-value>
        </init-param>
    </servlet>
</web-app>

I can access the "test1" parameter by calling getServletConfig().getServletContext().getInitParameter("test1").  But I cannot access the "test2" parameter at all.  For example calling getServletConfig().getInitParameter("test2") returns null.

Paul

Jason Bowman wrote:

 Hello,I had used the <init-params> successfully before. I have, however, just downloaded the latest version of Tomcat 3.2b6 and I am having the same problem you are. I personally believe that this is a bug that was introduced to the code and will post another message reporting that. I am curious thou, you said that you got <context-params> to work... how did you do this? Thanks,Jason B.
-----Original Message-----
From: Paul Hoepfner-Homme <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Thursday, October 26, 2000 12:27 PM
Subject: Re: Frustration with getInitParameter
 I have it set up *exactly* as you have described.  I am positive that I have defined web.xml correctly too.  I have written my servlet's class name correctly, and I have correctly defined init parameters for that servlet, but my enumeration of init parameter names (using config.getParameterNames()) has zero elements.

Paul

--
Paul Hoepfner-Homme
[EMAIL PROTECTED]

OVEN Digital | http://www.oven.com/
 
--
Paul Hoepfner-Homme
[EMAIL PROTECTED]

OVEN Digital | http://www.oven.com/
 

Reply via email to