File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts / glassfish: Encoding problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts / glassfish: Encoding problem" Watch "Struts / glassfish: Encoding problem" New topic

Struts / glassfish: Encoding problem

Mike Himstead
Ranch Hand

Joined: Apr 12, 2006
Posts: 178

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

Joined: Oct 29, 2001
Posts: 9189

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.

[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:

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 ]
I agree. Here's the link:
subject: Struts / glassfish: Encoding problem
It's not a secret anymore!