Abe, Thanks for the input. It is not that easy since I run TOMCAT on W2K as a system service. There is a batch file which allows settings of environment variables. However I think it would be better to set application specific variables in an application context and environment variables for container configuration only. But thanks for the input anyway.
Tom ----- Original Message ----- From: "Abraham Fathman" <[EMAIL PROTECTED]> To: "'Tomcat Users List'" <[EMAIL PROTECTED]> Sent: Tuesday, April 30, 2002 9:31 AM Subject: RE: server.xml - context parameter question > Tom, > > I haven't done this before but I thought that it might help you out. > > Instead of using the server.xml you could try adding your variables as > system properties. I believe you can do this by creating a setenv.sh/bat > file in your bin directory. Here you can set an environmental variable > JAVA_OPTS=-Ddbserer=dbserver. > > The catalina scripts should call this setenv script which will set the > JAVA_OPTS env variable. Then your code should be able to get this > property from the System.getProperty("dbserver") line. > > Just a thought. Hope it helps, > > Abe > > -----Original Message----- > From: Tom Bednarz [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, April 30, 2002 3:18 AM > To: Tomcat User List > Subject: server.xml - context parameter question > > > 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]> > > > > -- > To unsubscribe: <mailto:[EMAIL PROTECTED]> > For additional commands: <mailto:[EMAIL PROTECTED]> > Troubles with the list: <mailto:[EMAIL PROTECTED]> > > -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]>