Hi, This is an area of active discussion and work. You might want to follow the tomcat-dev list, especially the thread started yesterday on a CVS commit to address this.
Yoav Shapira Millennium Research Informatics >-----Original Message----- >From: Rick [mailto:[EMAIL PROTECTED] >Sent: Wednesday, July 28, 2004 9:12 PM >To: 'Tomcat Users List' >Subject: [5.0.27] change to setContentType() causing problem in UTF-8 >servlet, plz help > >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 > > > > > > This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
