users@jersey.java.net

RE: [Jersey] Integrated jsonp how to set JSONWithPadding http headers

From: saturon <gsaturon_at_gmail.com>
Date: Mon, 5 Oct 2009 16:36:28 +0200

Hi Paul,

Yes I've seen those.

Example:

From this:
 @GET
    @Produces({"application/xml;charset=UTF-8", "application/json"})
    public Response get( ...) {
        ....
        if (entities == null || entities.size() == 0) {
                throw new NotFoundException();
      }
        Response.ResponseBuilder r = Response.ok(data);
        r.expires(mDate);
        r.lastModified(now);
        r.build();
        return r;
   }

To this: The same method supporting jsonp
 @GET
 
@Produces({"application/x-javascript","application/xml;charset=UTF-8",
"application/json"})
    public JSONWithPadding get(
                @QueryParam("jsonp_callback") String callback,
                 ...) {
        ....
        if (entities == null || entities.size() == 0) {
                throw new NotFoundException();
      }
        // switch on media type
        if jsonp {
                return new JSONWithPadding (... );
        }
        
        //Question: how to set those header etc in case its not a jsonp
request...
        Response.ResponseBuilder r = Response.ok(data);
        r.expires(mDate);
        r.lastModified(now);
        r.build();
        return r;
   }


-----Original Message-----
From: Paul.Sandoz_at_Sun.COM [mailto:Paul.Sandoz_at_Sun.COM]
Sent: Montag, 5. Oktober 2009 16:09
To: users_at_jersey.dev.java.net
Subject: Re: [Jersey] Integrated jsonp how to set JSONWithPadding http
headers


Hi,

Can you give an example of how you want to use JSONWithPadding and why
you want to set the media type and/or response codes?

Have you seen the sample:

 
http://download.java.net/maven/2/com/sun/jersey/samples/jsonp/1.1.2-ea/j
sonp-1.1.2-ea-project.zip

?

Paul.

On Oct 5, 2009, at 3:26 PM, saturon wrote:

> I am right to assume that json with padding is not fully integrated
> into
> jersey media types at the moment?
>
> I just would like not to miss something existing before I start
> writing
> propetarity code.
>
> Thanks ;)
>
> -----Original Message-----
> From: saturon [mailto:gsaturon_at_gmail.com]
> Sent: Sonntag, 4. Oktober 2009 03:47
> To: users_at_jersey.dev.java.net
> Subject: [Jersey] Integrated jsonp how to set JSONWithPadding http
> headers
>
>
> Hi all,
>
> I am in process of integrating jsonp media type and would like to have

> this with my already supported types xml and json to be a transparent
> process.
>
>
> Right now JSONWithPadding is missing http header setting / response
> code
> methods... I am using jersey 1.1.2
>
> Solutions?
>
> Thanks, Ben
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
For additional commands, e-mail: users-help_at_jersey.dev.java.net