Search code examples
javatomcatweb-applicationswebspherewar

Java web application context


I have a Java web application. Inside the WAR I have a folder containing configuration files for the application. I need to know the path of the folder in order to load the files at runtime.

I also need the solution to work in Tomcat and in WebSphere.

Thanks.


Solution

  • I would suggest placing the files under WEB-INF/classes and simplying loading them from the classpath, not from the filesystem. This way, the path is always the same.

    You can use something like:

    InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("path");