| Author |
Struts / glassfish: Encoding problem
|
Mike Himstead
Ranch Hand
Joined: Apr 12, 2006
Posts: 178
|
|
Hi, I deployed a small application using Struts 1.3.8 to a glassfish v2 server at my local machine (Windows Vista x64). I experience a nasty encoding problem. My application should be unicode capable, but as it seems special characters (like German umlauts) get encoded wrongly. Debugging shows that a form parameter like "H�" is wrong when I check the form in the action. Where between the user's entry at the page and the action can characters become "misencoded"? The page: Or is glassfish the next thing to look at?
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8262
|
|
My wild guess is that your charset is UTF-8 and it doesn't support umlauts. Here is a discussion that concurs with this guess.
|
"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
|
 |
André-John Mas
Ranch Hand
Joined: Oct 18, 2008
Posts: 37
|
|
UTF-8 most certainly does support umlauts, and a whole range of other language scripts. If Glassfish is anything like Tomcat, then you will need to add a character set filter, otherwise the data will be treated as ISO-8859-1 and you will have all sorts of corruption. One you add to your project is documented here: http://wiki.apache.org/tomcat/Tomcat/UTF-8 A simple test to know whether your application is handling UTF-8 correctly is to pass some Chinese characters and see they don't come through corrupted. Here is the Babelfish translation for 'hello world' which you can use: 你好世界 An indication that you are using UTF-8 correctly is that a) the characters are not corruped, b) type values aren't being used. [ November 27, 2008: Message edited by: Andr�-John Mas ]
|
 |
 |
|
|
subject: Struts / glassfish: Encoding problem
|
|
|