Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Executing code before and after each request

Hi,

On Wed, Feb 5, 2014 at 6:32 PM, bubbleguuum <bubbleguuum@xxxxxxx> wrote:
> Hi,
>
> using Jetty 7, I wonder what is the best way to have code executed for each
> request,
> when the request starts being processed and when processing is finished (the
> response body written fully, or aborted by the client, or any other error).
>
> To illustrate this, suppose that I want to log the start and the end of
> processing of each request.
>
> Initially I though that a Filter would be appropriate, but although I can
> get the start of the request, I cannot get the end as the processing is
> async.
> What would be the best way to do this ?
>
> Alternatively, is there any API that returns the current number of pending
> requests ?

You said Jetty 7 and async processing.
What do you use for async processing ?
If you use Continuations, then you can implement
ContinuationListener.onComplete(...).

If you are on Servlet 3 API, there is a similar AsyncListener class.

-- 
Simone Bordet
----
http://cometd.org
http://webtide.com
http://intalio.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.


Back to the top