Bug 43236

Summary: Response.setCharacterEncoding() fails after Response.getWriter() and Response.reset()
Product: Tomcat 5 Reporter: Olaf Meske <bugs>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Severity: major CC: Udo.Walker
Priority: P2    
Version: 5.0.23   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Olaf Meske 2007-08-29 03:56:43 UTC
The class org.apache.catalina.connector.Response

resets the internal hold coyoteResponse and outputBuffer during reset():

    public void reset() {
        if (included)
            return;     // Ignore any call from an included servlet

but if anyone has already set the characterEncoding (e.g. to UTF-8) and already
got the writer, than all following invocations of request.setCharacterEncoding()
will do nothing, because the internal save flag for usingWriter is not reseted.
This is very annoying, because the coyoteResponse.reset(), resets the
characterEncoding to iso8859-1. So I have no change to change/reset the
charaterEncoding to UTF-8.
I'll think if you reset the response, you should also reset the usingWriter flag
or add another special flag, that works with this circumstances.
Comment 1 Mark Thomas 2007-12-18 15:48:50 UTC
This has been fixed in trunk and proposed for back port to 5.5.x and 6.0.x
Comment 2 Mark Thomas 2007-12-18 15:50:10 UTC
*** Bug 37072 has been marked as a duplicate of this bug. ***
Comment 3 Mark Thomas 2007-12-23 12:16:13 UTC
Fixed in 6.0.x
Comment 4 Mark Thomas 2008-01-06 15:15:53 UTC
Fixed in 5.5.x and will be included in 5.5.26 onwards.