users@jersey.java.net

ImplicitProduces annotation

From: Camel Christophe <ccamel_at_cls.fr>
Date: Mon, 28 Jun 2010 14:26:43 +0200

Hello everybody,

I desperately trying to configure Jersey to return a text/hml content
instead of application/xml with Chrome browser. When performing content
negotiation, Chrome sends the following acceptable media types, in the
following order :

application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,i
mage/png,*/*;q=0.5

Without any further Jersey customization, returned content is always
application/xml, and I believe this is expected.

So, to circumvent the problem, I added the ImplicitProduces annotation
to my resource, like this :

@Path("foo")
@ImplicitProduces("text/html;qs=5")
@Component
@Scope("singleton")
public final class FooResource {

...
    @GET
    @Produces( { MediaType.APPLICATION_XHTML_XML, MediaType.TEXT_HTML,
MediaType.APPLICATION_XML })
    public synchronized Response getFoo() {
        return ...
    }
...

}

But this doesn't work. Content returned is always application/xml. Is it
an already known problem ? I'm using Jersey 1.3.

Thanks for any help.