jQuery in Action, 2nd edition*
The moose likes Tomcat and the fly likes UTF-8 Encoding in my JSP: Tomcat 6 vs Tomcat 7 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "UTF-8 Encoding in my JSP: Tomcat 6 vs Tomcat 7" Watch "UTF-8 Encoding in my JSP: Tomcat 6 vs Tomcat 7" New topic
Author

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

N Goldsmith
Greenhorn

Joined: May 18, 2004
Posts: 22
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

Joined: Jun 10, 2012
Posts: 13

hi

In the first test page now :
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: UTF-8 Encoding in my JSP: Tomcat 6 vs Tomcat 7
 
Similar Threads
Ajax foriegn word issue
Unicode convert problem with Jboss in Linux
Sending characters to server using JSP <form> tag
transfering Euro (?) character
jsp include - utf-8 encoding problem