Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Chinese characters are not displayed correctly  RSS feed

 
Tejas Bavishi
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am entering following URL on the web browser:
http://localhost:8080/nbt4/pages/chinesesearch.jsp?crit=可回收包装

I have pasted following code of chinesesearch.jsp:


The following is printed on the browser:
List of products: 可回收包装
After conversion ???

The reason I am using the method getBytes(), is because on the tomcat console following message is printed:
Criteria in JSP((((())))) before unicode conversion - ???
Criteria in JSP((((())))) after unicode conversion - ???

Both request from web browser to server and the same value from server to web browser are printed properly in chinese. However, in the tomcat console, the characters are not displayed properly, instead of chinese characters, ??? are displayed. Please tell me how to resolve this ?

Also, when the query string parameter is passed to a Java bean as a string variable, and printed on console - the values come as garbage.

Has anybody had experience working with Chinese characters ? Please help.

I am using Tomcat 6, JDK 6 and Windows 7. Also, I have to run this solution in production environment running CentOS, JDK6 and Tomcat 6.

Thanks
Tejas
 
Madhan Sundararajan Devaki
Ranch Hand
Posts: 312
Java MS IE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From your post, I understand things work well on the web-front, but in the console the Chinese characters are not displayed properly. Tomcat console is not unicode configurable I guess, hence, the issue.
 
Tejas Bavishi
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the response.
Some questions:
(1) console should also have values printed in chinese, it must be working fine on windows os with chinese language. If yes whats the way to change this setting?
(2) the same tomcat is going to be deployed on CentOS, what OS level settings are required?
(3) when jsp page calls a java class method and i pass the chinese characters to this method, garbage special characters are displayed. Any code in java that handles utf 8 characters?
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tejas Bavishi wrote:(3) when jsp page calls a java class method and i pass the chinese characters to this method, garbage special characters are displayed. Any code in java that handles utf 8 characters?


That's not the right question. First of all there are no such things as "UTF-8 characters". There are only Unicode characters, which cover everything you will ever need. Including Chinese. And Java handles these characters natively. That means that your "Java class method" which receives Chinese characters and returns unexpected garbage must be badly written. Perhaps it contains ugly hacks like line 7 of your posted code? Or perhaps it's interfacing with something outside Java -- a database maybe -- which isn't configured correctly? You'd have to look at its code to see what is wrong.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!