Switching on UTF-8 Encoding
Hi What do I need to do so that data returned from Tomcat 4 is returned in UTF-8 encoding to a requesting browser and requests received are read as UTF-8. -- Cheers Tony。 - _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
Re: Switching on UTF-8 Encoding
You can use %@ page contentType="text/html;charset=UTF-8" % in the JSP or alternatively include the META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8" tag in your HTML. This will tell the browser to use the UTF-8 Encoding. Then when getting the requests, you can do a request.setCharacterEncoding ("UTF-8") before getting anything from the request to allow you to read in parameters as UTF-8. You could also try just reading in the parameters without setting that, and then doing param.getBytes("UTF-8"). I've been struggling with some encoding issues for a little while now, but I have it working, so if you have any other questions, please feel free to email me and I'll see if I can help. Good luck, -Jeff Antony Stace s45652001@yaTo: [EMAIL PROTECTED] hoo.com cc: Subject: Switching on UTF-8 Encoding 02/07/02 07:45 AM Please respond to "Tomcat Users List" Hi What do I need to do so that data returned from Tomcat 4 is returned in UTF-8 encoding to a requesting browser and requests received are read as UTF-8. -- Cheers Tony。 - _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED] -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
Re: Switching on UTF-8 Encoding
On Thu, 7 Feb 2002, Antony Stace wrote: Date: Thu, 7 Feb 2002 22:45:23 +0900 From: Antony Stace [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Switching on UTF-8 Encoding Hi What do I need to do so that data returned from Tomcat 4 is returned in UTF-8 encoding to a requesting browser and requests received are read as UTF-8. For writing UTF-8 content, your servlet needs to set the character encoding *before* it gets the response's writer: response.setContentType(text/html;charset=UTF-8); PrintWriter writer = response.getWriter(); writer.println(This line will be written in UTF-8); For reading, the browser should have set a character encoding on its Content-Type header. If it didn't (or if this is a GET request and you are trying to process query string parameters), call the following *before* calling any of the request.getParameter methods (or request.getReader): request.setCharacterEncoding(UTF-8); Note that this method was added in Servlet 2.3, so it won't work in Tomcat 3.x environments. -- Cheers Tony。 Craig -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
Re: Switching on UTF-8 Encoding
i did it by using filter, it works quite good From Timothy - Original Message - From: "Antony Stace" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, February 07, 2002 9:45 PM Subject: Switching on UTF-8 Encoding Hi What do I need to do so that data returned from Tomcat 4 is returned in UTF-8 encoding to a requesting browser and requests received are read as UTF-8. -- Cheers Tony。 - _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED] -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
Re: Switching on UTF-8 Encoding
Thanks Jeff, Timothy, Craig for your replies. I have a situation where I have a form which is UTF-8 format. In the servlet(I am acutally using struts) when I am processing a user request I use name = userForm.getName(); //Struts saves the information from a form in a Bean name = new String(name.getBytes(),"UTF-8"); I can then save the name value in a database without problems. I then use the contents of the Bean to write output in a jsp file but I get garbage. Does this mean that the format of the data in the Bean is incorrect? Should the values in this bean be written in a different format? If it is any use, I printed out the request and response encoding to a log file in the servlet, request.getCharacterEncoding() = null response.getCharacterEncoding() = ISO-8859-1 Cheers Tony On Thu, 7 Feb 2002 08:59:53 -0600 [EMAIL PROTECTED] wrote: You can use %@ page contentType="text/html;charset=UTF-8" % in the JSP or alternatively include the META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8" tag in your HTML. This will tell the browser to use the UTF-8 Encoding. Then when getting the requests, you can do a request.setCharacterEncoding ("UTF-8") before getting anything from the request to allow you to read in parameters as UTF-8. You could also try just reading in the parameters without setting that, and then doing param.getBytes("UTF-8"). I've been struggling with some encoding issues for a little while now, but I have it working, so if you have any other questions, please feel free to email me and I'll see if I can help. Good luck, -Jeff Antony Stace s45652001@yaTo: [EMAIL PROTECTED] hoo.com cc: Subject: Switching on UTF-8 Encoding 02/07/02 07:45 AM Please respond to "Tomcat Users List" Hi What do I need to do so that data returned from Tomcat 4 is returned in UTF-8 encoding to a requesting browser and requests received are read as UTF-8. -- Cheers Tony。 - _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED] -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED] -- Cheers Tony。 - _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
Re: Switching on UTF-8 Encoding
Hi Tony, The issue maybe in these places: 1. Request object - Jeff has covered the issue. 2. Database I/O - You have find out what type of Unicode encoding does the Database support. (UTF-8 or UCS-2). If it is UCS-2 then you have convert the data into UTF-8 at the java end. 3. The JSP's encoding should set as UTF-8. As mentioned by Jeff. Moreover the browser should have access to the appropriate fonts to show the data. Regards, Karthik - Original Message - From: Antony Stace [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Friday, February 08, 2002 8:33 AM Subject: Re: Switching on UTF-8 Encoding Thanks Jeff, Timothy, Craig for your replies. I have a situation where I have a form which is UTF-8 format. In the servlet(I am acutally using struts) when I am processing a user request I use name = userForm.getName(); file://Struts saves the information from a form in a Bean name = new String(name.getBytes(),UTF-8); I can then save the name value in a database without problems. I then use the contents of the Bean to write output in a jsp file but I get garbage. Does this mean that the format of the data in the Bean is incorrect? Should the values in this bean be written in a different format? If it is any use, I printed out the request and response encoding to a log file in the servlet, request.getCharacterEncoding() = null response.getCharacterEncoding() = ISO-8859-1 Cheers Tony On Thu, 7 Feb 2002 08:59:53 -0600 [EMAIL PROTECTED] wrote: You can use %@ page contentType=text/html;charset=UTF-8 % in the JSP or alternatively include the META HTTP-EQUIV=Content-Type CONTENT=text/html; charset=UTF-8 tag in your HTML. This will tell the browser to use the UTF-8 Encoding. Then when getting the requests, you can do a request.setCharacterEncoding (UTF-8) before getting anything from the request to allow you to read in parameters as UTF-8. You could also try just reading in the parameters without setting that, and then doing param.getBytes(UTF-8). I've been struggling with some encoding issues for a little while now, but I have it working, so if you have any other questions, please feel free to email me and I'll see if I can help. Good luck, -Jeff Antony Stace s45652001@yaTo: [EMAIL PROTECTED] hoo.com cc: Subject: Switching on UTF-8 Encoding 02/07/02 07:45 AM Please respond to Tomcat Users List Hi What do I need to do so that data returned from Tomcat 4 is returned in UTF-8 encoding to a requesting browser and requests received are read as UTF-8. -- Cheers Tony。 - _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED] -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED] -- Cheers Tony。 - _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED] -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
Re: Switching on UTF-8 Encoding
On Fri, 8 Feb 2002, Antony Stace wrote: Date: Fri, 8 Feb 2002 12:03:35 +0900 From: Antony Stace [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: Re: Switching on UTF-8 Encoding Thanks Jeff, Timothy, Craig for your replies. I have a situation where I have a form which is UTF-8 format. In the servlet(I am acutally using struts) when I am processing a user request I use name = userForm.getName(); //Struts saves the information from a form in a Bean name = new String(name.getBytes(),UTF-8); I can then save the name value in a database without problems. I then use the contents of the Bean to write output in a jsp file but I get garbage. Does this mean that the format of the data in the Bean is incorrect? Should the values in this bean be written in a different format? If it is any use, I printed out the request and response encoding to a log file in the servlet, request.getCharacterEncoding() = null response.getCharacterEncoding() = ISO-8859-1 This means that your browser didn't include a character encoding in it's Content-Type header on the form submission (sadly typical, unfortunately). If you know that you're running on a Servlet 2.3 environment (like Tomcat 4), you can call request.setCharacterEncoding() *before* calling any of the getParameter() methods, and Tomcat will do the translation for you. One approach to this is to use a Filter -- an example filter that does this sort of thing (SetCharacterEncodingFilter) is included in the WEB-INF/classes of the example webapp that is shipped with Tomcat 4. Cheers Tony Craig On Thu, 7 Feb 2002 08:59:53 -0600 [EMAIL PROTECTED] wrote: You can use %@ page contentType=text/html;charset=UTF-8 % in the JSP or alternatively include the META HTTP-EQUIV=Content-Type CONTENT=text/html; charset=UTF-8 tag in your HTML. This will tell the browser to use the UTF-8 Encoding. Then when getting the requests, you can do a request.setCharacterEncoding (UTF-8) before getting anything from the request to allow you to read in parameters as UTF-8. You could also try just reading in the parameters without setting that, and then doing param.getBytes(UTF-8). I've been struggling with some encoding issues for a little while now, but I have it working, so if you have any other questions, please feel free to email me and I'll see if I can help. Good luck, -Jeff Antony Stace s45652001@yaTo: [EMAIL PROTECTED] hoo.com cc: Subject: Switching on UTF-8 Encoding 02/07/02 07:45 AM Please respond to Tomcat Users List Hi What do I need to do so that data returned from Tomcat 4 is returned in UTF-8 encoding to a requesting browser and requests received are read as UTF-8. -- Cheers Tony。 - _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED] -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED] -- Cheers Tony。 - _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED] -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]