Click to See Complete Forum and Search --> : Changing Tomcat's working directory


nonamepub
07-15-2009, 09:48 AM
Hello All,

Would anyone know of a way to change Tomcat's working directory to something besides the bin directory? (e.g. [tomcat_install]\bin)

In case the answer is no, let me say that I'm trying to open a series of XML files from within my servlet. Currently, I have to write my paths relative to the bin directory, which is terrible. I want to keep the XML files in my WAR archive, and then have Tomcat execute out of the [exploded] project directory.

criterion9
07-15-2009, 10:27 AM
I found a couple of resources that may help you. Basically you need to load your resources based on the context path (not sure if I'm using the right name for it).

http://java.sun.com/javase/6/docs/api/java/net/URLClassLoader.html

http://jboss.org/file-access/default/members/jbossrichfaces/freezone/docs/apidoc_framework/org/ajax4jsf/resource/ResourceContext.html

It should be almost identical to loading additional resources from a JAR file.