Win a copy of OCP Oracle Certified Professional Java SE 11 Developer Practice Tests this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

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

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?


 
Greenhorn
Posts: 13
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

In the first test page now :
 
Water! People swim in water! Even tiny ads swim in water:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic