> From: Tim Watts [mailto:t...@cliftonfarm.org] 
> Subject: Re: Need Help!

> It sounds like you're trying to force your notion of what a web app's
> "current folder" should be onto Tomcat.

Code that depends on the current directory setting is naïve at best.

> The Servlet Spec makes no guarantee as to what the "current folder" is 
> (a file system notion) in a Servlet container or web app.

Actually, the servlet spec doesn't even require that there _is_ a file system 
accessible to servlet code, other than the work area provided by the spec 
interfaces.  Assuming that there is one goes well outside the bounds of the 
spec.
 
> Suggest you modify your file processing class to accept a hint as to the
> "current folder" and set that value in the servlet using
> ServletContext.getRealPath("/") and/or via an init parameter or via
> injection.  But note that if the web app is deployed as an unexploded
> war file getRealPath() may return null.

It's perfectly legitimate for a servlet container to _always_ return null for 
getRealPath(), so depending on that is like standing on a house of cards.  Much 
better to provide the absolute path to the directory of interest via a system 
or context property.  And, as noted elsewhere, the webapp deployment directory 
(if it exists) should always be treated as read-only.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to