users@jersey.java.net

Re: [Jersey] JSONWithPadding & Accept headers

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 24 Mar 2009 10:06:28 +0100

On Mar 23, 2009, at 10:21 PM, Magnus Eklund wrote:

> Hi
>
> I've successfully implemented a jsonp service using the
> JSONWithPaddingProvider. The problem I'm facing is that most
> browsers appear to be sending a wild card accept header (Accept:*/
> *) and not one the types supported by JSONWithPaddingProvider.

I am curious to know what browsers?


> Anyone have any ideas on how to solve this? I'd like to return a
> jsonp representation regardless of the accept header.
>


Off the top of my head this should work if you declare @Produces
("application/javascript"), or the complete list supported by
JSONWithPadding [1].

If the client sends Accept: */* the most acceptable media type will
be "application/javascript", and thus the padding should kick in.

If that behaviour does not work, then i think it is a bug.

Paul.

[1] https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/
jersey-1.0.2/api/jersey/index.html