tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 5333] - getRealPath("") without final \
Date Mon, 10 Dec 2001 04:47:03 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5333>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5333

getRealPath("") without final \

craig.mcclanahan@sun.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID



------- Additional Comments From craig.mcclanahan@sun.com  2001-12-09 20:47 -------
The Javadocs for getRealPath say this:

    Returns a String containing the real path for a given virtual path. For 
    example, the path "/index.html" returns the absolute file
     path on the server's filesystem would be served by a request for 
    "http://host/contextPath/index.html", where contextPath is the
     context path of this ServletContext.. 

For a directory, a path that does not end in a "/" character is valid on *all* 
operating system platforms, while a path that ends in "/" is only valid on some 
platforms.  However, the important issues is that both are valid on the majority 
of platforms.  Therefore, any application that makes any assumptions about 
whether or not there is a trailing slash are guaranteed to be non-portable, and 
should be corrected.

The standard approach to this (if your application logic requires a trailing 
"/") is to do something like this:

    String realPath = getServletContext.getRealPath(path);
    if ((realPath != null) && !realPath.endsWith("/"))
        realPath += "/";

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


Mime
View raw message