tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Remy Maucherat <>
Subject Re: Spec conflict between ServletResponse.getWriter() and ServletResponse.reset()
Date Fri, 02 Mar 2007 10:00:46 GMT
Mark Thomas wrote:
> Looking into bug 37072 has identified a conflict in the spec.
> Consider the following sequence of calls:
> response.setCharacterEncoding("UTF-8");
> response.getWriter();
> response.reset();
> After this the writer encoding and response encoding do not agree and
> can not be reconciled:
> - the Writer is using UTF-8 because the reset only clears the buffer,
> it doesn't reset the writer's encoding
> - response.getCharacterEncoding returns ISO-8859-1 due to the reset
> - response.setCharacterEncoding has no effect since the getWriter()
> call sets the usingWriter flag that prevents changes to the character
> encoding.
> The spec is clear that:
> - reset() clear all the headers

This means there's no way to send the char encoding, so this means it is 
reset as well.

> - calls setCharacterEncoding() have no effect after getWriter()
> What isn't clear is should the call to reset() also clear the writer
> (assuming of course that the response isn't committed)? Along the same
> lines is getWriter(), reset(), getStream() be legal?
> I am minded to clear the writer, buffer, stream and associated flags
> on reset().

It's not up to us (IMO) to start dealing with possible contradictions in 
the specification, esp when there's no use case for the situation, and 
the reports should be invalid. At least, unless you enjoy it, in which 
case it would be ok :)


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message