users@jersey.java.net

Re: [Jersey] Best way to pass data from a container/resource filter back to a resource object

From: Kevin Duffey <andjarnic_at_yahoo.com>
Date: Sat, 27 Mar 2010 20:29:28 -0700 (PDT)

That is how I've done it. Put the attribute/value on the request, access it from the service class.. and if you use a sub-resource, pass it as part of the method params for use in a sub-resource method if need be.

--- On Fri, 3/26/10, Marc Hadley <Marc.Hadley_at_Sun.COM> wrote:

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Subject: Re: [Jersey] Best way to pass data from a container/resource filter back to a resource object
To: users_at_jersey.dev.java.net
Date: Friday, March 26, 2010, 6:44 AM

If you are running in a Servlet container the you could try using an attribute in the ServletRequest (inject HttpServletRequest in both filter and resource via @Context).

Marc.

On Mar 25, 2010, at 6:13 PM, John Lister wrote:

> Hi, this seems an obvious thing but I can't seem to find an answer. What is the best/recommended way (if at all) of passing data from a container/resource filter back to the resource object after the filter completes..
>
> For example I have a container filter that does some checks after which I'd like to make the results available in the resource object, but I can't find a simple way to do it.
>
> At first I thought I could add a property to the ContainerRequest object passed to my filter method, but I can't seem to find a way to get access to this (either directly or via something else) in my GET function for example within the resource object.
>
> Any suggestions
>
> Thanks
>
> ---------------------------------------------------------------------
> 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