Rachel,

Thanks for that, about the static initializers... The classes that use them
are not servlets, merely utility classes are used in the web application and
also elsewhere.

For instance, a class, or series of classes that deal with database
connection pooling, could conceiveably have a configuration file to let them
know what pools to set up, min and max connections, where the server is,
what the driver class is, etc.  And these classes are useful in other apps,
not only in web applications.  Now of course you can hard code into the
class, the file to load, but this is ugly, it is nicer to say "java
-Ddb.properties=/home/stuart/db.properties".  As the classes are not
servlets, servletContext.getResource() is not really an option.

I could not find anything about TOMCAT_OPTS on the web site, persumably this
is an environment variable, what format do you put system properties in, is
it like
TOMCAT_OPTS="db.properties=/home/stuart/db.properties:myproperty=anotherprop
ertyvalue:.."?

Thanks for your help,

Stuart

-----Original Message-----
From: Rachel Greenham [mailto:[EMAIL PROTECTED]]
Sent: 17 November 2000 15:21
To: [EMAIL PROTECTED]
Subject: Re: System properties


On Friday 17 November 2000 14:27, you wrote:
> Hi,
>
> I was wondering if it is possible to pass properties to Tomcat.  I have
> some classes which read various system properties in their static
> initializers, and this works fine when using these classes on the command
> line using "java -Dproperty=value".  However I am not sure how to pass
> these properties into tomcat when I start it.  Is there something in one
of
> the XML files?

yes, you can do it, by supplying it in TOMCAT_OPTS when invoking Tomcat.

However, it's ugly and results in non-portable web applications (you need to

set the properties on whatever servlet container is being used, and restart 
it, and some may not allow you to set such things). It would be *better* to 
put the properties you want into some config file specific to your web 
application, in WEB-INF, to be loaded through ServletContext.getResource(), 
or as servlet init parameters. Static initialisers? Ugh. Specify instead
that 
your servlets are to be initialised and get the data then. Self-containment 
is the watchword for web applications.

-- 
Rachel

Reply via email to