users@jersey.java.net

Re: [Jersey] Serving another MIME than requested

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 19 Mar 2010 11:15:10 +0100

On Mar 18, 2010, at 8:43 PM, Markus Karg wrote:

> I have the need that my JAX-RS resource shall produce application/
> foobar+xml when a client actually request test/xml. How can I do
> that? When I just specify @Produces("application/foobar+xml") then a
> request for test/xml is rejected with 406. :-(
>
> Any ideas (besides manually setting the response header)?
>

Other than manually doing:

   @Produces("application/foobar+xml, text/xml")
   public Response x(...) {
     return Response.ok(..., "application/foobar+xml").build();
   }

you would need to write a resource-specific filter and use an
annotation to declare media type mappings, such that the filter would
modify the accept header accordingly.

Paul.