With Tomcat, normally when you deploy a .war file, it gets expanded and the 
context is run out of the directory created upon expansion, not the .war 
file itself.  For intance if you put a "myapp.war" file in 
TOMCAT_HOME/webapps (and haven't defined the context in server.xml because, 
if defined, it doesn't expand for some reason...known bug...) Tomcat 
automatically extracts the contents of the .war file to a directory called 
"myapp".  Then the context is run from that directory.

However, you can specify your appbase as the myapp.war file itself.  Tomcat 
can serve your entire application out of the archive.  Given this, 
myapp/WEB-INF is not on the file system.  It exists ony iside the archive 
where no file IO is possible.  So, a call to getRealPath"/") will return 
null because there is no real system file path to be found.

You can avoid this issue by always making sure to use your .war archive to 
distribute the app and make sure that the system is set up to expand the 
archive so the app is run out of a directory on the file system.

Hope that helps.

Jake

At 07:20 PM 7/17/2002 -0500, you wrote:
>I have a webapp that stores some data in an xml file. (I am using jdom to 
>read and write the xml files.)
>
>Right now I am using a construct like:
>
>String prefix = sc.getRealPath("/") + "/WEB-INF/dirName/";
>
>to get the path.  I then concatonate that with the file name and it works 
>fine.
>
>However, in the javadocs for javax.servlet I read:
>
>"This method returns null if the servlet container cannot translate the 
>virtual path to a real path for any reason (such as when the content is 
>being made available from a .war archive)."
>
>I am not exactly sure what this means.  If I deploy this application as a 
>.war, does the sc.getRealPath stop working?
>
>Thanks
>Paul Phillips
>
>
>--
>To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to