users@jersey.java.net

Setting response encoding

From: Franz Wong <franzwong_at_gmail.com>
Date: Sun, 13 Jun 2010 16:20:44 +0800

Hi,

I am dealing with a multilingual problem. When I redirected to a jsp page,
the non English characters cannot be shown correctly. e.g. "ÀR©]«ä" (Chinese
characters) would become "???" However, there is no problem with English
characters. How can I set the encoding to UTF-8?

Here is the sample code.

The service class

@GET
@Produces(MediaType.TEXT_HTML)
public Viewable retrieve() {
// some code here
// response is a POJO
response.setText("ÀR©]«ä"); // Non English characters here
        System.out.println(response.getText()); // The characters are
correctly displayed in the console
return new Viewable("/jsp/result.jsp", response);
}

The jsp

<input type="text" readonly="true" value="${it.text}"/>

I am using version 1.1.5.1.

Thanks.
Franz