[SERVLET_SPEC-10] Character encoding setting after ServletResponse#reset Created: 20/Sep/11  Updated: 13/Jan/12  Resolved: 13/Jan/12

Status: Resolved
Project: servlet-spec
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Shing Wai Chan Assignee: Shing Wai Chan
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

From javadoc, ServletResponse#reset will clear any data that exists in the buffer as well as the status code and headers. If the response has been committed, this method throws an IllegalStateException.

Once the headers are cleared, so is the charset in Content-Type.
If the getWriter() is already called, then according to javadoc of ServletResponse#setCharacterEncoding, one cannot set the encoding. In other words, only the default charset (in a given implementation) can used in this case.



 Comments   
Comment by markt_asf [ 21/Sep/11 ]

I assume that the proposed solution is that calling reset() also resets whatever tracking mechanism is used to determine that getWriter() or getOutputStream() has been called and thereby allowing the user to effectively start again.

Comment by Shing Wai Chan [ 21/Sep/11 ]

If we reset the state for determining whether getWriter() and getOutputStream() has been called, then we need to clarify what happens to existing Writer or OutputStream. Then we need to clarify the behaviors of the existing writer or outputstream.

Comment by markt_asf [ 22/Sep/11 ]

The spec should state that if the response is reset the Writer/OutputStream should no longer be used. Behaviour if there are used is undefined / throws ISE (I have have a slight preference for undefined since that means less work for me ).

As it happens, Tomcat will happily allow the Writer or OutputStream to be re-used although getWriter(), reset(), getOutputStream() will allow the Writer and OutputStream to be used together which might lead to some strange results.

Mark

Comment by Shing Wai Chan [ 13/Jan/12 ]

Sending javax.servlet/src/main/java/javax/servlet/ServletResponse.java
Transmitting file data .
Committed revision 52096.

Sending responseobject.fm
Sending status.fm
Transmitting file data ..
Committed revision 6.

Generated at Mon Aug 31 00:32:04 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.