Hi

I have a problem in initializing my web application. The application stores
all of its configuration parameters in a database table. My application has
an initialization servlet which loads beside other things the configuration.
Initially this is done in the init method, over time it is periodically done
in a separate thread.

The problem is, that I need to compose a JDBC connect URL. One of the
components of this URL is the name or IP address of the database server.
This information cannot be put in the web.xml of the web application since
it depends on the runtime environment and cannot be pre-defined at
development time. To access the configuration information in the database I
need this JDBC connect URL. So I was looking for a possibility to define
parameters OUTSIDE my web application.

I found a context tag under the host tag in the server.xml file. The TOMCAT
documentation says:

 --------  snip ------------------------
You can configure named values that will be made visible to the web
application as servlet context initialization parameters by nesting
<Parameter> elements inside this element. For example, you can create an
initialization parameter like this:

<Context ...>
  ...
  <Parameter name="companyName" value="My Company, Incorporated"
         override="false"/>
  ...
</Context>



This is equivalent to the inclusion of the following element in the web
application deployment descriptor (/WEB-INF/web.xml):

<context-param>
  <param-name>companyName</param-name>
  <param-value>My Company, Incorporated</param-value>
</context-param>



but does not require modification of the deployment descriptor to customize
this value.

-------------- end --------------------------

So I did the following:

<Context path="/MyWebapp" docBase="MyWebapp" debug="0" privileged="true">
     <Parameter name="DBServer" value="MyDatabaseServer" override="false"/>
</Context>

In the init() method of my initialization servlet (preload=1) I did the
following:

        for (java.util.Enumeration e = config.getInitParameterNames();
e.hasMoreElements();)
            mAppLog.debug("\t"+(String)e.nextElement());

where config is the ServletConfig object which is a parameter of the
HttpServlet.init(..) method. I expected to find the name DBServer as a
parameter name but it does NOT appear. Only those parameters defined in the
web applications web.xml file appear!

Could anybody explain me what I am doing wrong? What happens to context
entries in the server.xml file if the named context is NOT YET installed
e.g. is in the webapps directory as .war file?

Any help would be greatly appreciated.

Thomas


--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to