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:
return Response.ok("Hallo Stefan Zörner\n", "text/plain;
charset=utf-8").build();
You also need to change your method signature to return Response
instead of String.
HTH,
Marc.
On May 1, 2009, at 3:53 PM, Stefan Zoerner wrote:
> Hi all,
>
> I have a problem with Jersey, if the content provided by my REST
> service contains German Umlauts (äöüÄÜÖß).
>
> I have isolated the problem to a simple Hello like this:
>
> package hello;
>
> import javax.ws.rs.GET;
> import javax.ws.rs.Path;
> import javax.ws.rs.Produces;
>
> @Path("/helloworld")
> public class HelloWorldResource {
>
> @GET
> @Produces("text/plain")
> public String sayHello() {
> return "Hallo Stefan Zörner\n";
> }
>
> @GET
> @Produces("text/html")
> public String sayHelloInHtml() {
> return "<html><title>Hallo</title><body><h2>Hallo Stefan Zörner</
> h2></body></html>";
> }
> }
>
>
> If I consume this resource, the German Umlaut O (with dots on top of
> it), does not appear correctly on the client side. It does not
> matter, whether I use Grizzly, Tomcat with Spring etc., or if the
> contents comes from a database instead of the source code. Umlauts
> are wrong.
>
>
> I assume, there is an encoding problem, but I have no idea, where to
> configure that ...
>
> Here are some infos about my environment:
>
> Windows XP SP 2
> Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
> jersey-bundle-1.0.1.jar
>
> Problem occurs with Jersey 1.0.2 as well, btw.
>
>
> Any help is highly appreciated.
> Greetings from Hamburg,
> Stefan
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>