views:

32

answers:

2

Hi All,

I have a JSP that is supposed to display some German text from some .properties files by using fmt:message, e.g.

The corresponding entry in the .properties file is: service.test.hware.test = Hardware prüfen (umlaut between r and f in 2nd word).

On internet explorer this displays as:

Hardware prüfen

the umlaut being corrupted. Any ideas as to what is going on here? Note that we are using Spring MVC.

A: 
Mike Samuel
I have some further data on the problem. Most of the screens that use the above JSP fmt:message tag display correctly. I had to add a Spring controller to decide between two different JSPs to forward to. The problem with the umlaut only occurs when the controller is involved, links which go straight to a JSP can display the umlaut fine, if they go through the controller they do not display correctly.
fred basset
+3  A: 

The ü is typical for an UTF-8 originated ü being incorrectly encoded as ISO-8859-1 instead of UTF-8. Here's a programmatic evidence:

System.out.println(new String("ü".getBytes("UTF-8"), "ISO-8859-1")); // ü

Since you mention that the very same character from the properties file works fine in some JSP's, but not in other JSP's, then it means that the browser is by those JSP's not correctly been instructed to use UTF-8 to display the characters returned by the server.

This instruction happens in the HTTP Content-Type header. Using any HTTP header debugging tool, you must be able to figure the returned header. One of the popular tools is Firebug.

alt text

Note the presence of charset=utf-8.

Usually, in JSP this is achieved by simply placing the following line in top of the JSP file:

<%@ page pageEncoding="UTF-8" %>

See also:

BalusC
Thanks for the detailed answer. I checked the content-type being returned from the server and it is utf8 exactly as specified in your example. The JSPs in question do have <%@ page pageEncoding="UTF-8" %> as their first line too, still got the problem however.
fred basset
Can you confirm for 100% sure that it's the same property which you're displaying in the JSP's? And that the way of loading and rendering it is the same? Because the other cause of the problem can be in there.
BalusC