users@jersey.java.net

Re: [Jersey] Jersey/JAX-RS and async servlets

From: Chris Carrier <ctcarrier_at_gmail.com>
Date: Wed, 15 Sep 2010 09:38:34 -0700

I'm not sure exactly what your use case is but you can get around the
requirement for a resource class to return something by injecting an
HttpServletResponse instance into your method:

@Context HttpServletResponse response

Then you can use that object just like an old school servlet to send
responses back to the client via the response outputStream. Once you
close that stream the response is sent back and the method continues.
Then when you return null from that method it just gets ignored.

It's not pretty but it seems to work.

Chris

On Wed, Sep 15, 2010 at 9:12 AM, Chris Toomey <ctoomey_at_yahoo-inc.com> wrote:
> We're looking to use both Jersey/JAX-RS and Jetty async continuations (later
> the equivalent async mechanism in the Servlet 3.0 API) for implementing a
> web service, and looking at the JAX-RS spec.
> (https://jsr311.dev.java.net/nonav/releases/1.1/spec/spec.html) it looks
> like the API model is incompatible w/ the async continuations model.
> Specifically, it stipulates that resource class methods must return a return
> value and that if it's void, an immediate 204 response is sent.
>
> Can anyone confirm this or explain how a Jersey/JAX-RS resource method would
> suspend itself w/o causing the response to the client to be committed?
>
> thx,
> Chris
>
>