good point-http://java.sun.com/developer/technicalArticles/Intl/HTTPCharset/index -011206.htmlsuggests a webapp solution to embed the encoding param in web.xml e.g.<context-param> <param-name>PARAMETER_ENCODING</param-name> <param-value>UTF-8</param-value> </context-param>/*This way you can read the param for input request */ private String encoding; public void init() throws ServletException { ServletConfig config = getServletConfig(); encoding = config.getInitParameter("PARAMETER_ENCODING"); }
/*as well as accomodating the output response*/ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (encoding != null) { request.setCharacterEncoding(encoding); } ... } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } HTH/ M-- ----- Original Message ----- From: "Adrian Sutton" <[EMAIL PROTECTED]> To: "Tomcat Users List" <users@tomcat.apache.org> Sent: Friday, September 21, 2007 8:33 PM Subject: Re: How to control encoding of response.sendRedirect? (Tomcat 5.5.17) > On 22/09/2007, at 10:27 AM, Mark Thomas wrote: > > Alex Funk wrote: > >> if I use HTTPServletResponse.sendRedirect with a String that > >> contains an > >> URL with Unicode characters, the Location-Header contains the > >> characters > >> encoded in ISO-8859-1. I have set URIEncoding="UTF-8" in my > >> connector in > >> server.xml, since other links in my webapp use this encoding, so > >> that's > >> what I want also from my redirect URLs. Is there a way to let the > >> redirect URL be encoded in an other encoding or should the URL be > >> always > >> encoded with java.net.URLEncoder before calling 'sendRedirect'? I'm > >> searched the servlet spec and the web, but am still clueless. > > > > Check the HTTP spec. I am pretty sure (but haven't checked) that the > > headers must always be in ISO-8859-1. > > This is correct, however you can URL encode the URL with UTF-8 to get > unicode characters to pass through safely. Most modern user agents > handle UTF-8 encoded URLs correctly. > > Regards, > > Adrian Sutton > http://www.symphonious.net > > --------------------------------------------------------------------- > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]