Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts / glassfish: Encoding problem

 
Mike Himstead
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9256
9
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
André-John Mas
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic