users@jersey.java.net

Re: [Jersey] JSONWithPadding & Accept headers

From: Magnus Eklund <magnus.eklund_at_gmail.com>
Date: Tue, 24 Mar 2009 15:29:44 +0100

On Mar 24, 2009, at 10:06 AM, Paul Sandoz wrote:

>
> 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?
>

I am actually seeing this in both Safari 4 and FF3. I'm not sure if it
was clear from my post, but that what I'm trying to do is to load the
jsonp representation by programatically creating scrip-tags as
outlined here http://blogs.sun.com/japod/entry/workarounding_cross_domain_restriction_with
  and here http://www.theurer.cc/blog/2005/11/03/how-to-build-a-maps-mash-up/
  .

>
>> 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.
>

It does work. Thank you. I think I had complicated things with custom
media type mappings.

> Paul.
>
> [1] https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0.2/api/jersey/index.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>