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.
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.
Not many get the right opportunity !
posted 9 years ago
thanks for the response.
(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?
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: