Where should configuration files be stored in a web application?
Created May 4, 2012
Alex Chaffee The current servlet spec (2.2) doesn't mention specifically where to store configuration files. The new version (2.3) will have a more explicit way of accessing them.
In the meantime, a good technique is to put them in the *root* level of your WEB-INF/classes directory. (e.g. "mywebapp/WEB-INF/classes/config.txt".) Since this directory is automatically on your classpath, you can load the files using
InputStream in = this.getClass().getResourceAsStream("/" + filename); if (in == null) throw new IOException("Resource " + filename + " not found");