Hi!
I have a serious encoding problem while using Google Maps encoding Service in a Java EE Applikation. I use Glassfish v3 as App Server on Windows 7. Furthermore i use JSF 2.0 and Mojarra 2.0.2, Facelets 1.1.14, Primefaces 2.0, JAAS, JSP API 2.2, Servlet API 2.5 .
I use this code to (reverse)geocode the variable "address".
Example address = "Doggenriedstraße, Weingarten, Germany".
[i] URL url = new URL("
http://maps.google.com/maps/geo?q="
+ URLEncoder.encode(address, "UTF-8")
+ "&output=json&sensor=false&key=" + "ABQ...")[/i]
When i evaluate the response, special characters like: "ß" or "ä, ö, ü" are encoded in Windows-1252 (subset of ISO-8859-1) or something. Example: "ß" is encoded as "ß". When i use the application on a Mac OS the special characters are also wrong encoded, it is not Windows-1252 but something Mac specific. When i enter the same URL to the Firefox Browser - the response encoding is correct. So it has something to do with Glassfish or Grizzly i don't know.
I have tried much to solve the Problem:
- all files are encoded in utf-8, all xml-like files have the tag <?xml version="1.0" encoding="UTF-8"?>
- in the sun-web.xml i use: "<parameter-encoding default-charset="UTF-8"/>"
- in the web.xml i use:
[i] <context-param>
<param-name>com.sun.faces.disableUnicodeEscaping</param-name>
<param-value>auto</param-value>
</context-param>
<locale-encoding-mapping-list>
<locale-encoding-mapping>
<locale>en_US</locale>
<encoding>UTF-8</encoding>
</locale-encoding-mapping>
<locale-encoding-mapping>
<locale>no</locale>
<encoding>UTF-8</encoding>
</locale-encoding-mapping>
<locale-encoding-mapping>
<locale>de</locale>
<encoding>UTF-8</encoding>
</locale-encoding-mapping>
</locale-encoding-mapping-list>[/i]
- I use a utf8-filter:
[...]
[i]public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
request.setCharacterEncoding(encoding);
response.setCharacterEncoding(encoding);
chain.doFilter(request, response);
}[/i]
-> I noticed that the response object's character encoding is "ISO-8859-1" every time the doFilter function is called. In the filter i set it manually to utf-8, that works, but next time the doFilter method is called, the same happens. The request object's character encoding is always utf-8.
So i think the problem has something to do with glassfish or facelets??
Can someone please help me?
[Message sent by forum member 'michael7186']
http://forums.java.net/jive/thread.jspa?messageID=399187