aspose file tools*
The moose likes Tomcat and the fly likes Tomcat Unicode [was: jQuery.ajaxForm Chinese Characters] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat Unicode [was: jQuery.ajaxForm Chinese Characters]" Watch "Tomcat Unicode [was: jQuery.ajaxForm Chinese Characters]" New topic
Author

Tomcat Unicode [was: jQuery.ajaxForm Chinese Characters]

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

I'm having a time with posting chinese characters to the server. I have the following:



The ajaxForm is posting chinese content but when I look at the header content it is changed. I post in the text field 请选择基色 but what gets put in the header is ����€‰�‹��Ÿ��‰�.

And the some other gibberish comes back out. As far as I know everything is set to use UTF-8. The JSP, JavaScript, from what I understand, is UTF-8 by default, the response. Other code on the server that is chinese (entered directly into the database) displays fine which is why I think it has something to do with what is happening in the browser before it even gets to the server.

Any tips?
[ March 07, 2008: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

A bit of an update. I noticed that the content-type in the header being sent to the server is "text/plain". I was able to tell apache to ALWAYS use UTF-8 regardless of what the page states so now I get "text/plain; utf-8" which is, maybe, half way there.

What I am expecting is "text/html; utf-8" and I am not understanding why the POST isn't being sent like this even though the page is sent as such.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

I moved this to the Tomcat forum because the exact same code works fine in weblogic which leads me to believe this has to be a Tomcat issue since that is the only difference between the two environments.

Weblogic seems to set the header correctly and all is well. Tomcat does not. I've been googling but not coming up with much so any help would be appreciated.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Have you tried explicitly setting the character encoding to "text/html; charset=UTF-8"

in your JSP or servlet?
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletResponse.html#setCharacterEncoding(java.lang.String)
http://java.sun.com/j2ee/1.4/docs/api/index.html
[ March 07, 2008: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat Unicode [was: jQuery.ajaxForm Chinese Characters]