tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Layman <randy.lay...@aswethink.com>
Subject RE: Problems with <init-param>
Date Wed, 08 Aug 2001 15:30:16 GMT

	The answer really lies in how the spec indicates that instances of
servlets are supposed to work.  For each seperate URL pattern that a servlet
responds to, a different instance is created.  Each instance receives its
own (seperately defeined) set of init-parameters.

	The spec never specifies the /servlet/className and this feature is
provided by Tomcat only because so many people want the feature.  These
servlets (created by the servlet invoker) are a seperate instance from your
URL pattern defined servlet, and therefore has a different set of
parameters.

	If you really wanted this to work, the one workaround that I can
think of right now it to set static variables in the servlet from the init
method.  Then you would need to make sure that only the correct servlet set
the init parameters (like pass a parameter named "GoodSet" and only if that
parameter is defined with a specificed value would you actuall set the
static variables).

	Randy

> -----Original Message-----
> From: Claes Holmerson [mailto:claes.holmerson@pipechain.com]
> Sent: Wednesday, August 08, 2001 11:51 AM
> To: 'tomcat-user@jakarta.apache.org'
> Subject: Problems with <init-param>
> 
> 
> Hello!
> 
> I can not get the init-parameters that I specify in web.xml to work
> correctly. When I invoke the servlet as 
> 
> http://localhost:8080/pipechain/servlet/se.masystem.pipeline.w
> eb.servlet.Log
> inServlet 
> 
> then in init(ServletConfig):
> 
> config.getInitParameter("propertyfile");
> 
> returns null, but if I invoke the servlet with 
> 
> http://localhost:8080/pipechain/login
> 
> it works! Should not these urls be equivalent? (Tomcat 3.2.2)
> 
> /Claes 
> 
> (please cc me as I don't subscribe to the list)
> 
> 
> 
> Below is the relevant fragment from web.xml:
> 
>     <servlet>
>         <servlet-name>
>             Login
>         </servlet-name>
>         <servlet-class>
>             se.masystem.pipeline.web.servlet.LoginServlet
>         </servlet-class>
>         <init-param>
>             <param-name>propertyfile</param-name>
>             <param-value>start.properties</param-value>
>         </init-param>
>     </servlet>
> 
>     <servlet-mapping>
>         <servlet-name>
>             Login
>         </servlet-name>
>         <url-pattern>
>             /login
>         </url-pattern>
>     </servlet-mapping>
> 
> 
> 
> ----------------------------------------------------------------------
> Claes Holmerson
> PipeChain AB
> Porfyrvägen 14		+46 (0)46 32 52 42     office phone
> SE-224 78 LUND		+46 (0)709 89 52 42   mobile phone
> Sweden			+46 (0)46 15 10 74     office fax
>                            
> http://www.pipechain.com/
> --------------------------------------------------------------
> ----------
> 

Mime
View raw message