This is a simple example on how to get the WEB-INF directory path in a J2EE web application.
public class MyClassName{ private static final String WEBINF = "WEB-INF"; public String getWebInfPath(){ String filePath = ""; URL url = MyClassName.class.getResource("MyClassName.class"); String className = url.getFile(); filePath = className.substring(0,className.indexOf(WEBINF) + WEBINF.length()); return filePath; } }
Hi, good post. I have been wondering about this issue,so thanks for posting. I’ll definitely be coming back to your site.
Thanks! really helpfull
Simple but very helpfull, thanks Melandri