users@jersey.java.net

Re: [Jersey] Noobie question, sorry: pre-filtering requests

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 14 Aug 2008 09:00:50 +0200

On Aug 14, 2008, at 6:30 AM, Jim Powers wrote:

> Ok, so I'm finally digging into this, I followed the thread here:
>
> http://markmail.org/search/?q=list%3Anet.java.dev.jersey.users
> +filter#query:list%3Anet.java.dev.jersey.users%20filter+page:1
> +mid:p7yxygz4wpakqno5+state:results
>
> I can get my filter working this way, kinda. The real problem is that
> these kinds of filters only have access to the request object. My
> filter needs to be able to set (at least) return codes (403, 5XX) and
> stop the request if things "go wrong" but the Response object is not
> passed in. For the time being I'm doing this as a regular Servlet
> filter, unless there is a better way ;-).
>

You can throw a javax.ws.rs.WebApplicationException. The constructor
can take a Response instance you can build using
Response.ResponseBuilder or take just a status code.

Paul.

>
> --
> Jim Powers
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>