You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Fnystal <fn...@get2net.dk> on 2000/10/08 10:07:52 UTC
context parameters
I have added the following data to a web.xml file, in the hope that I could
point to a configuration file. From the logs, I can see that the file is
read (I got duplicate errors, before I delete the stuff from the default
web.xml in the $TOMCAT/conf dir.
<context-param>
<param-name>conf</param-name>
<param-value>/usr/local/tomcat/webapps/xitema/WEB-INF/classes/InetSale/InetSale.conf</param-value>
</context-param>
I have a test servlet which reads all init parameter with the following code:
out.println("<BR>Initparameters:");
Enumeration e = getServletConfig().getInitParameterNames();
String tmps = null;
while (e.hasMoreElements()) {
if ((tmps=(String)e.nextElement())!=null)
out.println("<BR>InitParam "+tmps+" = "+
getServletConfig().getInitParameter(tmps));
}
Unfortunately this doesn't return any init parameters.
Please help..... I'm trasnferring my project from JServ to Tomcat in order
to user the news servlet API. In JServ, I added a defaultinitparam to the
zone.properties file and it worked.
Re: context parameters
Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Fnystal wrote:
> I have added the following data to a web.xml file, in the hope that I could
> point to a configuration file. From the logs, I can see that the file is
> read (I got duplicate errors, before I delete the stuff from the default
> web.xml in the $TOMCAT/conf dir.
>
> <context-param>
> <param-name>conf</param-name>
> <param-value>/usr/local/tomcat/webapps/xitema/WEB-INF/classes/InetSale/InetSale.conf</param-value>
> </context-param>
>
> I have a test servlet which reads all init parameter with the following code:
>
> out.println("<BR>Initparameters:");
> Enumeration e = getServletConfig().getInitParameterNames();
> String tmps = null;
> while (e.hasMoreElements()) {
> if ((tmps=(String)e.nextElement())!=null)
> out.println("<BR>InitParam "+tmps+" = "+
> getServletConfig().getInitParameter(tmps));
> }
>
This call returns initialization parameters for your *servlet*, not for your *context*. To get the values
entered via <context-param>, do this instead:
getServletContext().getInitParameter(tmps);
Craig McClanahan
====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00): Sun Technical Briefing
Session T06 (24-Oct 14h00-15h00): Migrating Apache JServ
Applications to Tomcat