Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Enabling async

Philip Healy wrote:
> Hello all,
> 
>   I am trying out the new Servlet 3.0 async API with Jetty 8.0.0.0 M0.
>  When I call request.startAsync() in doGet() I get an exception:
> 
> java.lang.IllegalStateException: !asyncSupported
>  
> I found a post from Greg stating that async must be enabled in the
> handler that the servlet is hosted in.  How do you do this
> programatically (i.e., without using web.xml)?

For servlet 3.0, you need to set the asyncSupported
state on all the filters and servlets that the request
goes through.   You can do this in a 3.0 web.xml
or you can do it programmatically on the ServletHolder
and FilterHolder classes.

If you use the jetty continuation API, you don't need to
set this.   Also, to answer your question asked privately,
neither Servlet 3.0 async API nor continuations will help
you detect a connection that has closed.

You can only detect that by trying to write something
to it and getting an IOException.

But a suspended request will eventually either be resumed
or timeout.    To do cleanup code, you can register a
listener with onComplete implemented and it will always
be called once the request lifecycle is complete.

The async onError callback is only to notify an async
handler if a flush from an async complete call fails
(or similar).

regards





Back to the top