DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24584>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24584

Make VelocityViewServlet fall back to response.getOutputStream() if getWriter() fails





------- Additional Comments From [EMAIL PROTECTED]  2003-11-11 19:25 -------
+  index = defaultContentType.indexOf('=', index + CHARSET.length());
+  if (index >= 0)

This check is to assure a well-formed Content-Type header.  A user could've
started typing in their content type property as "ShiftJIS; charset" and been
interrupted by their significant other, resulting in a misconfiguration.  I'm
also not positive if the '=' character is required to be flush against the
"charset" string -- I know the "charset" string can have zero or more space
characters between it and the ';' separator.


Regarding the "encoding" instance member, calling setContentType() only applies
to getWriter(), not to getOutputStream().  Since the later is for writing bytes
(binary data), on its own it performs no encoding transformation and must be
wrapped in a Writer which has a character set specified via its constructor.

http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/ServletResponse.html#setContentType(java.lang.String)
http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/ServletResponse.html#getOutputStream()
http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/ServletResponse.html#getWriter()

What we could do is override setContentType() to have it record the desired
character set for later use.  This seems in line with your sub-classing comment,
but will incur a slightly higher runtime overhead.  What do you think?


Regarding use of PrintWriter over Writer, the Servlet API returns a PrintWriter
from its getWriter() method.  I was trying to be consistent with that.  Your
suggestion is fine with me though -- I'll switch it over.


Also still to do: modify error() to also attempt the fall-back to
getOutputStream() using a shared private method for acquiring a Writer instance.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to