tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <>
Subject Re: Tomcat 5.0.30 - UTF-8 encoding not working
Date Thu, 02 Jun 2005 18:56:43 GMT
Karanjkar, Sanjay V (IT) wrote:
> Hi msjava,
> I'm trying to migrate our webapp from ServletExec4.1.1/JDK1.3.1 to Tomcat5.0.30/JDK1.4.2.
> On ServletExec, our app was showing/saving UTF-8 strings correctly. However, after migration
to Tomcat, the pages are not showing UTF-8 encoded content correctly.

If your are POSTing your data, request.setCharacterEncoding("UTF-8") 
should do the trick but you MUST call this before any parameters are read.

If you are encoding your data in the URI, you will need to set the 
URIEncoding attribute on the coyote connector to "UTF-8" to ensure that 
the URI is decoded correctly.

> Do I need to do something else for Tomcat? In particular, do I need to do the stuff mentioned
1. Yes
2 & 3 - No . These might work under some circumstances but 2. is trying 
to change a read-only property and 3. is hacking around the data not 
being handled correctly in the first place.

When I am testing this, I use the following JSP to make sure Tomcat is 
correctly configured. A clean Tomcat install should only require 
URIEncoding="UTF-8" to be added to the connector in server.xml for these 
to work for any UTF-8 data. You should test it with both method="post" 
and method="get"

<%@ page contentType="text/html; charset=UTF-8" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
     <title>UTF-8 test page</title>
     <p>UTF-8 data posted to this form was:

     <form method="post" action="index.jsp"
       <input type="text" name="mydata">
       <input type="submit" value="Submit" />
       <input type="reset" value="Reset" />

If this works, then the chances are your app isn't quite right. If you 
have a test case that doesn't work (try and make it as simple as 
possible) post it to the list and I'll take a look.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message