File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Issue with Form Input in JSP Request with japaneese characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Issue with Form Input in JSP Request with japaneese characters" Watch "Issue with Form Input in JSP Request with japaneese characters" New topic
Author

Issue with Form Input in JSP Request with japaneese characters

echarish Kumar
Ranch Hand

Joined: Feb 02, 2010
Posts: 42
Hi, i am working on a Japaneese Project and have a JSP developed in Struts, i am facing a issue with the input character, i have set the Request Encoding as SHIFT_JIS and whenever i submit a characte '-'(\uff0d) it gets converted into '−'(\u2212), i want to stop this automatic conversion from happening, regarding which i need help i.e. how to impliment a solution which will stop this conversion on the whole application.
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 347
Where and how exactly are you setting the encoding as SHIFT_JIS ?
Ravi Majety
Ranch Hand

Joined: Feb 26, 2009
Posts: 59

use the encoding as "UTF-8" instead of SHIFT_JIS
echarish Kumar
Ranch Hand

Joined: Feb 02, 2010
Posts: 42
i have created a Filter which set the request encoding as SHIFT_JIS, if i set this encoding to UTF-8 the input japaneese characters become junk. i am not able to find a proper solution to this.

req.setCharacterEncoding("SHIFT_JIS");

i have to set this to get the input japaneese characters properly but due to this '-'(\uff0d) is getting changed to '−'(\u2212)
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 347
Can you check what is the Content-Type in the http request is?

You could do this by using firfox and and the firebug plugin.
Look under the Net tab in firebug. You could also use some other tcp monitoring tool..
echarish Kumar
Ranch Hand

Joined: Feb 02, 2010
Posts: 42
Response Headersview source
Charset is UTF-8

Server Apache-Coyote/1.1
Set-Cookie JSESSIONID=66A8EE3E764AC0230EAE66B2AC3B1742;
Content-Type text/html;charset=UTF-8
Transfer-Encoding chunked
Date Tue, 24 May 2011 12:19:44 GMT
Request Headersview source
Host localhost:8080
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Connection keep-alive
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 347
Hmm.. if the content is encoded as UTF-8 shouldn't it be read as UTF-8?

You say when you set this to UTF-8 the japanese input characters become junk.
Could you explain how exactly you see this junk? Is it through some console?
echarish Kumar
Ranch Hand

Joined: Feb 02, 2010
Posts: 42
m able to see the the junk in the debug mode of the eclipse, and also when i take this input and display them again on next jsp they come out as junk.
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 347
would you be able to print this out on the eclipse console?
For this do the following and see..

Read the characters as UTF-8

Run | Debug Configurations | Select tab Common
Under encoding select other and UTF-8

You may also have to do the following too..
Go to Eclipse > Preferences > General > Appearance > Colors & Fonts > Debug > Console font
choose a Unicode font see if Arial Unicode MS is available...

Really these are a few shots in the dark..
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 347
Hi Echarish, have you made any progress?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Issue with Form Input in JSP Request with japaneese characters
 
Similar Threads
Displaying Japanese characters in JSP
org.apache.struts2.dispatcher.Dispatcher serviceAction Could not find action or result
Issue with Jsp's multiple request going to same jsp
localesdata.jar
JSP getting distored when changing charset to UTF-8 from SHIFT_JIS