views:

22

answers:

1

Hello everybody,

this question is somewhat related to this question: StackOverflow: Howto load a resource from WEB-INF directory of a web archive

I want to use StringTemplate and want to load my templates via a StringTemplateGroup. Until know I use the method shown in the related question to get single files from the WEB-INF folder, but as I read here, it is considered bad practice to load the templates via a path as the application could be inside a WAR file AND I can not use the StringTemplateGroup because of the path.

Is there a way to achieve this that you would recommend? Can I get the entire folder as a stream-like object for the StringTemplateGroup to read or is there a decent (and not so hackish) way already implemented in StringTemplate?

I am somewhat new to Java but willing to learn :) Thank you very much in advance.

A: 

You can add the property of context paht into JVM runtime arguments,for example, in Tomcat container,you add an argument -DcontextPath=[somewhere] into startup.sh file, and then get the path of context by System.getProperty("contextPath").The context path also can get from -Dcatalina.base in Tomcat.

Mercy
This does not solve the issue when the app is inside a WAR file, or does it? And I am looking for a more general approach that will work without modifing the unerlying server. I mean - come on, this problem must be somewhat common..
ThE_-_BliZZarD