DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=33973>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=33973

           Summary: Retrieving static content files with UTF names
           Product: Tomcat 5
           Version: 5.0.30
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: [EMAIL PROTECTED]


I have a 2 servers one with configuration en_US.UTF-8 and another with
en_US.ISO8859-1.

When i list a directory inside the container, files with special chars (latin
chars in my case) are displayed correctly but when i try to retrieve a file or
navigate through a directory tomcat says - not found file
"/prueba/%C3%B1o%C3%B1o/" -, that its the desired file name but coded with 
UTF-8.

Looking at the DefaultServlet.java code i found this line on method 
getRelativePath:

...
   result = request.getServletPath();
...

As i understand, the link (created by the self container, method renderHtml ) to
the file is coded with UTF-8 but when the file name is re-created in the servlet
is not encoded back; getServletPath returns the file string but in a like
ISO-8859-1 coding, so obviously it will never find the file because the physical
file %C3%B1o%C3%B1o doesnt exist. 
So i did this change to DefaultServlet.java

...
result = new String(request.getServletPath().getBytes("ISO-8859-1"),"UTF-8");
...

this way, as i think, whatever encoding sends the browser (even null) the
getBytes return the name as a simple ASCII string and then the String
constructor creates the name with the right UTF-8 encoding  This patch works on
my both servers.

This works fine for static content but i think that developers can do something
similar to let servlets or jsps have filenames with special chars, although in
my opinion as a good coding standard these should be named in plain ascii.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to