tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <ma...@apache.org>
Subject Spec conflict between ServletResponse.getWriter() and ServletResponse.reset()
Date Fri, 02 Mar 2007 04:18:04 GMT
Looking into bug 37072 has identified a conflict in the spec.
http://issues.apache.org/bugzilla/show_bug.cgi?id=37072

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
- 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().

Thoughts?

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message