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=37072>.
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=37072

           Summary: Encoding mismatch in error condition
           Product: Tomcat 5
           Version: 5.5.9
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: [EMAIL PROTECTED]


I found a possible bug in the class org/apache/catalina/connector/Response.java.

I try to explain the problem with steps of the request flow (I use a filter, a
servlet and a JSP page):

1. Tomcat gets a request from outside
2. The filter gets the response and does the following:
2.1 Sets the character encoding to UTF-8
2.2 Gets the writer with response.getWriter() and writes out a message if the
content type is text/html. This locks the writer which means you can not set the
character encoding later anymore.
3 The servlet gets the request and an exception occurs (this is a simulated
exception)
4 Tomcat gets back the request and processes the error
4.1 The response is reset:
4.1.1 the response itself is reset
4.1.2 the outputstream is reset
4.1.1+2 both are reset to ISO-8859-1 which is the default value.
5 The error page is called which has the encoding UTF-8. 
5.1 BUG: The encoding of the page is not used because the writer is still locked
but the encoding in the writer is set to default which is ISO-8859-1

My suggestion is to let the character encoding be untouched in the error case
because in the error case the encoding was already set somewhere before (e.g.
filter or servlet).

1. Tomcat (ISO-8859-1, writer unlocked)
2. Filter (-> UTF-8, writer locked)
3. Servlet (UTF-8, exception raised, writer locked)
4. Tomcat (ISO-8859-1, writer locked)
5. JSP (UTF-8 <-> ISO-8859-1 conflict because writer still locked ->
setCharacterEncoding is locked)


With regards
Udo Walker

-- 
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