[EMAIL PROTECTED] wrote:
I would like my web-app to read in a *.properties file at startup (not for
i18n, but the good old
java.util.Properties, for example to get the e-mail address of the admin of
the web-app). So
I wrote a ServletContextListener which will load the properties-file and
store it into servlet
context from where it can be accessed throughout my web-app. But where I do
have to
put the myProps.properties file? I tried WEB-INF/classes, but I get a
FileNotFoundException.
Or do I have to configure web.xml or struts-config.xml in some way? Or is
there a better
way to store the required data (such as admin's e-mail)?

Where to put the file all depends on how you want to load it... If you want to load it from the classpath (e.g. using getResources()) then yes, it needs to be somewhere under WEB-INF/classes. The path you specify should be relative to WEB-INF/classes, slash-separated and include the full file name (e.g. foo/bar/baz.properties if you have a file baz.properties in WEB-INF/classes/foo/bar).

An alternative would be to store your config in an XML file like Struts does and use Digester to load it, but if you only have a few simple name/value pairs to load it's not worth the complexity.

L.
--
Laurie, Open Source advocate, Java geek and novice blogger:
http://www.holoweb.net/laurie


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to