tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <ma...@apache.org>
Subject Re: Request parameter data not being recognised as UTF-8
Date Thu, 21 Jul 2005 18:50:37 GMT
Tim Koop wrote:
> I have a web page form that is expecting UTF-8 data, but when my code 
> gets the data, the getParameter() methods don't return the right thing.  
<snip>
> In server.xml, I have added these lines to each Connector:
>  URIEncoding="UTF-8"  useBodyEncodingForURI="false"
>  (I have also tried useBodyEncodingForURI="true")
Leave this as false.
> I have added this text to JAVA_OPTS (in my rc.d init script) and have 
> confirmed that these are indeed Java system properties
> -Djavax.servlet.request.encoding=UTF-8 -Dfile.encoding=UTF-8
I am not sure if the first one of these will do anything and I am 
certain the second will not - it is a read only property on most JVMs.

> I have tried calling request.setCharacterEncoding("UTF-8") in my code.  
> I've even made it the first line of the jsp page.  No luck.
This is good.

> I even have the environment variable LANG set to "en_GB.UTF-8"
Not necessary.

> 
> I have <%@ page contentType="text/html; charset=UTF-8"  
> pageEncoding="UTF-8" %> in my jsp page.
Good.

> I have <meta http-equiv="Content-Type" content="text/html; 
> charset=utf-8"> in my jsp page.
Not necessary.
> Should this actually work and I'm just doing something wrong?
Yes it should (and does for me) work.

> Is there anything else I can try?

1. Try accessing Tomcat directly to see if mod_jk is causing problems.
2. Try 4.1.31 - it has a bunch of bug fixes that might (I haven't 
checked the release note for details) help
3. Try the following simple test JSP and once this works, see how your 
app is different.

<%@ page contentType="text/html; charset=UTF-8" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
   <head>
     <title>Encoding fun</title>
   </head>
   <body>
     <p>Data posted to this form was:
     <%
       request.setCharacterEncoding("UTF-8");
       out.print(request.getParameter("mydata"));
     %>

     </p>
     <form method="post" action="index.jsp"
           enctype="application/x-www-form-urlencoded">
       <input type="text" name="mydata">
       <input type="submit" value="Submit" />
       <input type="reset" value="Reset" />
     </form>
   </body>
</html>

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message