users@jersey.java.net

Re: [Jersey] Response Filter and Exceptions

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 10 Oct 2008 10:08:01 +0200

On Oct 10, 2008, at 2:48 AM, Craig Iverson wrote:

> Thanks so much for fixing this and the quick turn around.
>
> A couple of things I've noticed others discussing and I would love
> to see them get put into jersey are:
> A convenient way to get the form parameters from a filter.
>

OK. There potential side-effects in doing this since we cannot
guarantee that the actual resource method processing the encoded form
parameters will process them in the same manner as the filter (e.g. it
could just forward things to something else or parse them
differently). Thus we would need to buffer the bytes.


> A convenient way to fill a pojo from the form parameters and request
> parameters.
>

You can do it for anything but form parameters [1].


> Maybe I'm just out dated on these items.
>

You are up to date. Could you log an issue?

Paul.

[1] http://blogs.sun.com/sandoz/entry/parameter_beans

> Thanks again,
> Craig
>
>
>
>
> This is fixed in the latest snapshot.
>
> Paul.
>
> On Oct 8, 2008, at 12:02 PM, Paul Sandoz wrote:
>
> >
> > On Oct 8, 2008, at 11:47 AM, Paul Sandoz wrote:
> >
> >>
> >> On Oct 8, 2008, at 12:29 AM, Craig Iverson wrote:
> >>
> >>> I have a filter that implements both ContainerRequestFilter and
> >>> ContainerResponseFilter. I was hoping when an Exception was
> >>> thrown it would still go through the response filter. This does
> >>> not seem to be the case. I have some generic logic I want to
> >>> apply to a response no matter what happens. This logic uses data
> >>> from the request and sets things in the responses. Any ideas how
> >>> to have this generic logic applied to the Exception case?
> >>>
> >>
> >> We have a bug.
> >>
> >> When exceptions are thrown they may be mapped to responses. Filters
> >> can throw exceptions as well as terminate the filter chain and
> >> those exceptions can be mapped.
> >>
> >> I think we need to do the following:
> >>
> >> 1) Enable response filters to operate on the response regardless of
> >> whether it was produced from a request filter
> >> a resource class, or mapped from an exception; and
> >>
> >> 2) If the filter throws an exception and the response was mapped
> >> from an exception. Then the filter chain
> >> terminates and the exception is mapped to a response.
> >>
> >
> > A refinement for 2): if a response filter throws an exception then
> > the filter chain terminates and the exception is mapped to a
> response.
> >
> > Paul.
> >
> >> Will that work for you?
> >>
> >> Paul.
> >>
> >>
> >>
> ---------------------------------------------------------------------
> >> 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
>