[EMAIL PROTECTED] wrote:
Hi!
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)?
You can put context parameters in web.xml:
<context-param>
<param-name>PARAMETER_X</param-name>
<param-value>xxx</param-value>
</context-param>
//You then access it by:
servletContext.getInitParameter("PARAMETER_X");
http://forum.java.sun.com/thread.jspa?threadID=498993&messageID=2364171
If you need to access the properties outside of the "web layer", i.e.
you don't have a reference to the request object because you're in some
other layer of the app, then you can use some kind of properties
manager. Here's a related thread:
http://marc.theaimsgroup.com/?l=struts-user&m=111808953102759&w=2
Another way to do this is to use JNDI.
- Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]