users@jersey.java.net

Re: [Jersey] Setting response encoding

From: Franz Wong <franzwong_at_gmail.com>
Date: Sun, 13 Jun 2010 21:55:22 +0800

FYI

Instead of setting the encoding with <meta> only, I have set <%_at_page
contentType="text/html; charset=utf-8" %> and now jetty works.

Franz

2010/6/13 Franz Wong <franzwong_at_gmail.com>

> Thanks for your suggestion. However, that code cannot be compiled. And I
> changed to @Produces("text/html; charset=utf-8").
>
> Although the problem still exists, I just found that Tomcat works correctly
> while Jetty does not. I need to figure it out the reason then.
>
> Franz
>
>
> On Sun, Jun 13, 2010 at 8:05 PM, Suneel Marthi <suneel_marthi_at_yahoo.com>wrote:
>
>> Try this:
>>
>> @Produces(MediaType.TEXT_HTML;MediaType.ACCEPT_CHARSET="UTF-8")
>>
>>
>>
>> ------------------------------
>> *From:* Franz Wong <franzwong_at_gmail.com>
>> *To:* users_at_jersey.dev.java.net
>> *Sent:* Sun, June 13, 2010 4:20:44 AM
>> *Subject:* [Jersey] Setting response encoding
>>
>> 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
>>
>>
>