Does anyone know how to set an absolute path to the webApp attribute in a Host?
Something like "c:\...."
I can't figure out how to do it. Tried with "/", tried with "\" and nothing worked.
I am using tomcat 7.0 on Windows XP platform.
I'm not quite sure what a "webApp attribute" is, although if you're referring to a resource in a WAR, absolute filesystem paths aren't a good idea. For one thing, unless the WAR has been exploded, the closest you could get would be the filesystem path of the WAR file itself. And for your own sake, don't even even THINK about writing data into a WAR, exploded or not!
In most cases, the best way to address resources in a WAR is to use their WAR pathname: for example, "/WEB-INF/classes/log4j.xml". Even in DOS/Windows filesystems, this path should be using forward slashes and not backslashes as path separators. It's usually safer in Java to use the forward-slash notation anyway. Backslashes can bite you.
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: Sep 30, 2011
Hi Tim, Thank you for the reply.
I need the absolute path for development purpose: I have local library on which I develop and write the code. Once it is ready I upload it to SVN and pack it to a WAR file.
Of course it is not a good idea to have the under development code under the Tomcat library so I want the local instance of Tomcat to have the option to load an application from an absolute path.
Anyway I found my two mistakes:
The first was posting this message with a typo I was suppose to write "appBase" instead of "webApp"
The second was using the wrong path to my application.
You can put a path in the Context element that you use to deploy the webapp with. In the case of a test setup like what you've got, your best best is to create an "xxx.xml" file containing the Context element and copy it into TOMCAT_HOME/conf/Catalina/localhost.
Please note that the context name in the Context XML element will be ignored if you do this, and the actual URL that the app is deployed under would be "xxx" (http://localhost:8080/xxx), so name that file appropriately!
And, yes, for the Context appBase, you SHOULD supply an absolute path. Relative paths are OK, but not as foolproof. So that would give you something like this: