• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Chinese characters are not displayed correctly

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 312
MS IE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic