I have created a class that extends PropertyMessageResources to read Property-Files from outside the Webapplication called MyMessageResources. It works fine. Now I want to store the url or the Path in web.xml like this:
can you please explain me a little more? I haven't enough experience with Struts. Please help me with this topics:
- Where should I put the code to read the property from web.xml and set to MyMessageResource? You say "when your app starts". Should I extends a class? Which place is this?
- It means that after the MessageResourceFactory creates MyMessageResources I should read the value from the web.xml and set this value on MyMessageResources, right? Should I write my own code to read the web.xml file? When no, hoy can I read on this context (start from app) the web.xml file?
I'd suggest you use an environment vaiable rather than a context parameter. To access a context parameter, you have to have a reference to the ServletContext object, while you can access an environment variable from any class as long as it's runnning in the web application. Example:
code in MyMessageResource (probably in the constructor)