At many places in my web application I need a certain String which is :
request.getServletContext().getRealPath("/");
// I can only get this once the web-app starts
Sometimes a simple java class needs to know this string. I don't want to pass each and every time this string to the class's function. One way could be to stash this string in a file at the very beginning of the web application. Every time I would need this, simply read the file.But this doesn't seem a pretty good option. Is there any other way out ?
May be I can store in the context.xml
of the application. If it is possible how do I do that ?
If there is a better way please suggest.
I am using tomcat as the server.