users@jersey.java.net

Re: [Jersey] Try to catch all invalid requests

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 13 May 2009 11:28:07 +0200

Hi Daniel,

It is possible to process 404 responses by writing a container
response filter:

   https://jersey.dev.java.net/nonav/apidocs/1.1.0-ea/jersey/com/sun/jersey/api/container/filter/package-summary.html

That will catch all request not processed by the programmer and
requests that are processed that return 404 responses. Since the above
supports a larger set of cases that you stated i am not sure if that
is sufficient for your needs.

Currently there is no way to catch a request that did not match.
However, it should be easier to add some state to the
ContainerResponse to indicate whether the request was matched or not.

It is not possible to write a resource class that is invoked if a
request does not match, but i suppose that might be easy to support if
required and the above does not meet your requirements.

Paul.

On May 13, 2009, at 1:53 AM, Drew Daniel wrote:

> Hi Everyone,
>
> I was hoping that someone has already tried this before. Is there a
> way that jersey can catch all requests for which no paths are
> defined in the Java class. Much like a switch statement where there
> is a 'default' case which traps all requests which are not defined
> by the programmer. I hope I am able to communicate clearly what I am
> looking for. If this is somewhat ambiguous please let me know.
>
> Thanks
>
> Socal_Dev