I am looking at
http://java.net/jira/browse/SERVLET_SPEC-10
(" Character encoding setting after ServletResponse#reset")
The following are proposals:
A. We will update the behavior of ServletResponse#reset() as follows:
Clears any data that exists in the buffer as well as the status code and
headers.
*If getWriter() or getOutputStream has been called, then it will set
back the previous character encoding.*
If the response has been committed, this method throws an
|IllegalStateException|.
(In other words, the character encoding is not reset once
getWriter() or getOutputStream has been called.)
B. We will update the behavior of ServletResponse#setCharacterEncoding
as follows:
This method can be called repeatedly to change the character
encoding. *If getWriter() and then reset() are called, then this method
can be called once.* Otherwise, this method has no effect if it is
called after |getWriter| has been called or after the response has been
committed.
(Comparing with (A), this approach allows the reset of character
set, but not getting a different writer/outputstream.)
C. We will update the following:
(i) ServletResponse#setCharacterEncoding
This method can be called repeatedly to change the character
encoding. This method has no effect if it is called after |getWriter|
has been called or after the response has been committed.
This method has no effect if *|reset| has not been called then this
method will have no effect after *called after |getWriter| has been
called or after the response has been committed.
(ii) ServletResponse#reset()
*The method will also reset the status of calling getWriter() and
getOutputStream(). In other words, one can call getWriter() even if
getOutputStream has been called before reset().*
*If getWriter() or getOutputStream has been called, then the behavior of
using those objects will be undefined after reset has been called.*
(This approach will allow stale objects.)
(A) and (B) seems to less complicated as there are no stale objects, but
cannot switch the use of writer and outputstream.
Any comments?
Shing Wai Chan