users@glassfish.java.net

How do we override the charset iso-8859-1 set by glassfish with UTF-8 ?

From: <glassfish_at_javadesktop.org>
Date: Thu, 22 Jul 2010 12:07:58 PDT

Our Webapp has several ajax calls that hit a servlet on the server that may return Unicode characters(Greek,Spanish).

These characters are garbled when viewed on page because the encoding style set by glassfish is always: iso-8859-1

We always see the Content-Type text/html; charset=iso-8859-1 for every ajax call response in spite of setting the response encoding and content-type for the rsponse.

        response.setCharacterEncoding("UTF-8");
        response.setContentType("text/plain; charset=UTF-8");

also tried changing the domain.xml settings:

default-response-type
forced-response-type

        <http-listener acceptor-threads="1" address="0.0.0.0" blocking-enabled="false" default-virtual-server="server" enabled="true" family="inet" id="http-listener-1" port="80" security-enabled="false" server-name="" xpowered-by="true">
          <property name="cometSupport" value="true"/>
          <property name="chunkingDisabled" value="false"/>
          <property name="default-response-type" value="text/plain; charset=UTF-8"/>
          <property name="forced-response-type" value="text/plain; charset=UTF-8"/>
        </http-listener>
        <http-listener acceptor-threads="1" address="0.0.0.0" blocking-enabled="false" default-virtual-server="server" enabled="true" family="inet" id="http-listener-2" port="443" security-enabled="true" server-name="" xpowered-by="true">
          <property name="cometSupport" value="true"/>
          <property name="chunkingDisabled" value="false"/>
          <property name="default-response-type" value="text/plain; charset=UTF-8"/>
          <property name="forced-response-type" value="text/plain; charset=UTF-8"/>
        </http-listener>

is there any way we can change the encoding to UTF-8 for servlet response?

-pavan
[Message sent by forum member 'achantap']

http://forums.java.net/jive/thread.jspa?messageID=478309