> From: Sasikumar Muralikrishnan [mailto:sasiku...@pointelsolutions.com] 
> Subject: RE: Reg. getRealPath("/") _ How does the result of this method 
> differ in Tomcat 7 and Tomcat 8

> But here, I am not writing anything inside the web application.

> 1. I have a flat file in the web application and it has some configurations
> details, which I use for the project.
> 2. Therefore, we are trying to read the configuration detail from that file.
> 3. And as I mentioned earlier it works fine until tomcat 7. Now, we are
> planning to upgrade to tomcat 8.0.14 and facing this issue.

Any application depending on getRealPath() is inherently flawed.  There is no 
guarantee in the servlet spec that getRealPath() will ever return anything 
other than null, since there's no guarantee that deployment occurs within the 
file system.  It's unfortunate that this interface still exists; it should have 
been deprecated long ago.

The proper way to read data packaged within the webapp is to use 
ServletContext.getResourceAsStream(), which is required to work regardless of 
the packaging and deployment.

 - 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