users@jersey.java.net

[Jersey] Re: Handling a special URI.

From: Jan Algermissen <algermissen1971_at_mac.com>
Date: Thu, 02 Dec 2010 21:39:07 +0100

Rahul,

On Dec 2, 2010, at 9:30 PM, Rahul Babbar wrote:

> Hello All,
>
> I have a few Jersey resources which handle different URIs.
>
> Lets say i have two resources, handling /foo and /bar.
>
> I have a requirement in which any URI of the form /<anything>/{Id}/{SOME KEYWORD}/{name} should not go to the resource handling foo or bar even though anything is foo or bar.
>
> Eg, lets say, the URI is of the form /foo or /foo/1 or /bar or /bar/1 , it will go to the corresponding resource handling the URI.
>
> However if the URI is of form /foo/CUSTOM/1 or /bar/CUSTOM/1, i need it to go to a different resource directly.

I think this is problematic with JAX-RS. You could do it by handling /foo/ with one resource and then dispatch to other based on parameters, but that IMHO works against the simplicity of JAX-RS.

Have you considered using a rewriting reverse proxy in front of Jersey?

Jan


>
> Sorry but i know this requirement is a bit weird, but is there a way to accomplish it?
>
> Thank you
>
> Rahul