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 \

[EMAIL PROTECTED] changed:

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



------- Additional Comments From [EMAIL PROTECTED]  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:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to