Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

UTF-8 Encoding in my JSP: Tomcat 6 vs Tomcat 7

 
N Goldsmith
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using Tomcat 6.0.24 and Tomcat 7.0.5. I have the same JSP in both. When I enter multibyte chars as my username in the code below, I get back 2 different results.
My input is: 今天天气很好今天天气很好

Tomcat 6.0.24: username:�天天��好�天天��好
Tomcat 7.0.5: username: &_#20170;&_#22825;&_#22825;&_#27668;&_#24456;&_#22909;&_#20170;&_#22825;&_#22825;&_#27668;&_#24456;&_#22909;
(remove '_'. Added to keep browser from converting)

Uncommenting the setCharacterEncoding line does nothing to change the result.
I have also tried this: new String(request.getParameter("username").getBytes("iso-8859-1"), "UTF-8");
and setting the page encoding:
<%@ page language="java"contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> both with no luck.

Any ideas why the data is converted differently between Tomcat versions, both using the same JRE: 1.7.0.25?


 
amir kawaja
Greenhorn
Posts: 13
Firefox Browser Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

In the first test page now :
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic