On 2/10/2015 9:14 AM, Sasikumar Muralikrishnan wrote:
Hi André Warnie,

Great thanks for your response.

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.

Please let me know about your valuable thoughts/suggestions.

It looks to me like you're not going to be able to do this without some code changes (or just stay in TC 7 for now). Either check for the existence (or not) of the trailing "\" and fix the path string accordingly, or since the file you're trying to read is inside your context, build the name from the context path rather than the real path. Either way needs code changes, but the second one is more portable than the first option.



Thanks, 
Sasi Kumar M.


-----Original Message-----
From: André Warnier [mailto:a...@ice-sa.com]
Sent: Tuesday, February 10, 2015 2:29 PM
To: Tomcat Users List
Subject: Re: Reg. getRealPath("/") _ How does the result of this method
differ in Tomcat 7 and Tomcat 8

Sasikumar Muralikrishnan wrote:
Hi Team,

Using this method

getServletContext().getRealPath("/")

returns '\' at the end when I run my project in Tomcat 7 whereas it is not
working as such in Tomcat 8.

For example,
In Tomcat 7 it returns as "D:\Tomcat\webapps\project\"
In Tomcat 8 it returns as "D:\Tomcat\webapps\project"

At present the project is in production so, I am unable to change the code
in every part(where i use getRealPath("/")). Is there a way/setting in
tomcat level configuration to make it resolved.

Additional information,
        
Tomcat version : 8.0.14

OS : Windows server 2008 R2 standard

System Type: 64 bit operating system

Thanks,
Sasi Kumar M.

Hi.
I do not know the answer to your question.
But maybe now would be a good time to examine why you are using
getServletContext().getRealPath(), and to browse the following thread for
some good
reasons not to be doing that.
http://tomcat.markmail.org/thread/5vfsnf56w2r5gz6q



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



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




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

Reply via email to