Win a copy of Svelte and Sapper in Action this week in the JavaScript 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Chinese characters are not displayed correctly

 
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
 
Ranch Hand
Posts: 312
MS IE Java
  • 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?
 
Marshal
Posts: 25826
69
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.
 
Been there. Done that. Went back for more. But this time, I took this tiny ad with me:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic