Christopher Schultz wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dave,

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.

That's generally how things are done.
Thanks for confirming that. Previously, I had been using the java Preferences class, which stores things in a way that is transparent to the java program (in the registry on windows, elsewhere on other OS's). It works, but is something of a pain for initial setup, because it has some strange ways of specifying key names, and won't find them if there are any mismatches. I much prefer text files for configs, but for a long time didn't know there were built-in capabilities for this in java, and didn't want to bother to roll my own.

Chuck's note about using ServletContext.getResourceAsStream is a good
one. Since Properties files are always in ISO-8859-1, there's no really
good reason to use a Reader. Just get the stream and allow
Properties.load to read from it.

ServletContext.getResourceAsStream always loads things relative to the
context root (and can look in the WAR file, etc.), so Chuck's example of
"WEB-INF/myConfig.properties" will load a file found in
/your/path/to/deploy/your-webapp/WEB-ING/myConfig.properties".
Yes, that's what I figured out by experimenting, but again, thanks for confirming that I interpreted things correctly.

Dave



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to