Re: Application context available for non-WW classes

Eduardo Cordeiro <[email protected]>
Newsgroups gmane.comp.java.open-symphony.webwork
Message-ID <22942688.1150337426433.JavaMail.os-j2ee@opensymphony01.managed.contegix.com>
In case anyone ever wonders about this, I've managed to solve the problem using a ServletContextListener, and then, upon context initialization, saving the result of ServletContext.getRealPath into one of my application's singleton classes.

It's pretty simple: just create a class that implements the javax.servlet.ServletContextListener interface and store the context information needed into one of the application's classes (as a static field or field of some 'config' singleton) in the body of the contextInitialized that this interface declares.

Then you must also register the listener in web.xml, e.g.:
<listener>
<listener-class>util.ContextListener</listener-class>
</listener>

Regards,
Eduardo Cordeiro
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=34279&messageID=66942#66942

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.