users@jersey.java.net

Re: [Jersey] Issue with German Umlauts in output

From: Stefan Zoerner <szoerner_at_apache.org>
Date: Fri, 01 May 2009 23:11:36 +0200

Hi Marc,

thanks for your immediate response.

Marc Hadley wrote:
> How are you viewing the output ? You should receive UTF-8 encoded
> strings unless you override it. If you are using a browser you may have
> to manually tell it to treat the page as UTF-8. You can also specify
> this in the response like this:

I have used different ones, none worked. Firefox, curl, a ServiceMix
consumer ... But now it works quite well. Firefox now presents the
responses including umlauts, after I followed you hint.

This is how my sample code looks like now (just in case someone else has
comparable problems):

@GET
@Produces("text/plain")
public Response sayHello() {
        return Response.ok("Hallo Stefan Zörner\n", "text/plain;
charset=ISO-8859-1").build();
}

@GET
@Produces("text/html")
public Response sayHelloInHtml() {
        return Response.ok("<html><title>Hallo</title><body><h2>Hallo Stefan
Zörner</h2></body></html>", "text/html; charset=utf-8").build();
}


It works quite well. Only my curl still seems to have trouble with
UTF-8; I have therefore modified the charset - now it works.

Thanks again, I am quite happy.

Greetings from Hamburg,
     Stefan