Hi all,
I have a servlet that gets a bunch of data from the DB and returns in the
form of XML, in UTF-8. This has been working with all the 5x versions until
5.0.27. It seems to be caused specifically by the change listed in the
change log.
org.apache.cayote.tomcat5.CayoteResponse.java
----------------------------------------------------------------------------
----------------------
ServletResponse.setContentType sets response encoding after getWriter was
called (Bugtraq 5062838) (luehe)
----------------------------------------------------------------------------
----------------------
Now, my servlet is unable to set the character set to UTF-8 as illustrated
in.
----------------------------------------------------------------------------
----------------------
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException
{
Document doc = XMLUtil.getNewDocument();
. populate document .
response.setContentType("text/xml;charset=UTF-8");
PrintWriter out = response.getWriter();
out.write(XMLUtil.docToString(doc));
}
----------------------------------------------------------------------------
----------------------
Even though the setContentType is called before getWriter, the new code
added in this release seems to be filtering out the "charset=UTF-8". I
have removed the only filter created by me in the access of said servlet, I
know of nothing that would be calling the getWriter before I call
setContentType. So I do not understand how to set the charset at this
point. I assume there is some kind of workaround that I haven't seen. Any
help would be greatly appreciated.
Thanks in advance,
Rick