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

If you just want to execute code when the request enters the context
and then leaves the context after exiting the last servlet/filter, you
can use a javax.servlet.ServletRequestListener.

If you want to know when the response IO is finished, that's a
different matter - doyou leave it up to the container to flush the IO
or do you do it in the servlet, or if you do Continuations then see
Simone's response.

cheers
Jan

On 11 February 2014 05:37, Simone Bordet <sbordet@xxxxxxxxxxx> wrote:
> 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.
> _______________________________________________
> jetty-users mailing list
> jetty-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/jetty-users



-- 
Jan Bartel <janb@xxxxxxxxxxx>
www.webtide.com
'Expert Jetty/CometD developer,production,operations advice'


Back to the top