You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Patrick Clark <pa...@hotmail.com> on 2000/04/01 21:19:45 UTC

problems

I am having a problem using the <context-param> tag within my web.xml file 
of my new wepp application.

I want to be able to tell every servlet the value of a parameter that
indicates the location of a configuration file.  This configuration file 
includes important information about the database connection and such.

Re: problems

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Patrick Clark wrote:

> I am having a problem using the <context-param> tag within my web.xml file
> of my new wepp application.
>
> I want to be able to tell every servlet the value of a parameter that
> indicates the location of a configuration file.  This configuration file
> includes important information about the database connection and such.
>
> >From my servlet I am trying to get the init parameters with this java:
>
>       String s = this.getInitParameter("ConfigFile");
>
> Here is my web.xml from within my SimpleApp/web-inf directory:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <!DOCTYPE web-app
>     PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
>     "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
>
> <web-app>
>   <context-param>
>     <param-name>ConfigFile</param-name>
>     <param-value>C:\configuration\config.txt<param-value>
>   </context-param>
> </web-app>
>
> I get no parameters.
>
> Am I using this correctly?  Is this what I should do to pass information to
> every servlet in my web app?
>

Context parameters become initial parameters of the servlet context, not of
each individual servlet.  Try this instead:

    String s =
      getServletContext().getInitParameter("ConfigFile");

>
> Thanks,
> Patrick
>

Craig McClanahan