tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 55837] ServletContext.getRealPath() returns null
Date Wed, 04 Dec 2013 12:22:55 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=55837

--- Comment #3 from Mark Thomas <markt@apache.org> ---
The short version is that this should return a file (that doesn't exist) in
this case.

The long version is that this is just about defined in the Servlet
specification but only tenuously.

The use of virtual path and real path in the Javadoc
ServletContext.getRealPath() and HttpServletRequest.getPathTranslated()
suggests strongly that they have the same meanings in both cases.

HttpServletRequest.getPathTranslated() states it has the "Same as the
value of the CGI variable PATH_TRANSLATED". A little googling lead me to
RFC 3875. While that is not a formal standard, it does define 'current
practice' which is as good as you are ever going to get for CGI.

Section 4.1.6 of RFC 3875 addresses PATH_TRANSLATED. At the top of page
15 about half way through section 4.1.6 there is the following text:
"The value is derived in this way irrespective of whether it maps to a
 valid repository location."

Therefore a real path doesn't have to exist.

Therefore getRealPath() doesn't can return a file that doesn't exist.

Finally, there is nothing I could see in the spec that prevents getRealPath()
returning a valid file even if that file does not exist.

Given I had to dig into this for the Servlet EG I'm surprised that Tomcat 8 is
doing the wrong thing. Probably an oversight on my part. I'll take a look.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message