My preference is JNDI (<env-entry> ) for such things.
Then in web.xml - you can create a default entry in web.xml"
<env-entry>
<env-entry-name>configFile</env-entry-name>
<env-entry-value>/etc/stuff</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
Then it can be overridden in your context config:
<Context ...>
<Environment name="configFile" value="/opt/config/etc/stuff"
type="java.lang.String" override="false"/>
</Context>
Then looked up in java via:
***
import javax.naming.Context;
import javax.naming.InitialContext;
InitialContext initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
String myConfigFile = (String) envCtx.lookup("configFile");
***
More details:
http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html
Individual parameters can be set this way too. I don't like system
properties since its global to the JVM and not local to the webapp. If
you have a library which needs a different config (or version) which
needs to live in a different webapp that relies on a system property -
then you end up in trouble.
-Tim
David Kerber wrote:
This is a followup to my question about startup parameters. After
digging around a bit, it looks like my best bet is to use the Properties
class to read my settings from a disk file at startup. The properties
api appears to be easy to use, and works very similarly to the
Preferences class. My question is how to locate the file without
hard-coding its location. I have looked at several possibilities, and
can't work out the details on any of them even after a bunch of
googling. :-(
1. Pass the location of the file as a JVM -D argument at app startup.
But I can't figure how how to pick that value up inside my app.
2. Put the config file somewhere in the tree of my webapp, such at
docbase or in conf. But again, I can't figure out how to pick that
location in a form I can use to read the file in with a FileReader object.
3. ???
---------------------------------------------------------------------
To start a new topic, e-mail: [email protected]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]