users@jersey.java.net

[Jersey] Specifying additional Servlets in the url pattern handled by Jersey

From: Rahul Babbar <rahul.babbar1_at_gmail.com>
Date: Thu, 9 Dec 2010 16:22:49 -0800

Hi All,

I have this following requirement.

rest/foo;A=B should go to a fooServlet.
rest/<Anything>/<Anything>/descriptor should go to DescriptorServlet(which
may be a normal Servlet handled without Jersey)

In my web.xml, i have given,

<servlet>
<servlet-name>Jersey</servlet-name>

<servlet-class>org.*.*.*.configuration.JerseyServletContainer</servlet-class>
                ........init-params...............
 </servlet>
 <servlet>
 <servlet-name>DescriptorServlet</servlet-name>
<servlet-class>org.*.*.*.DescriptorRESTService</servlet-class>
 </servlet>

       <servlet-mapping>
<servlet-name>Jersey</servlet-name>
 <url-pattern>/rest/*</url-pattern>
</servlet-mapping>
 <servlet-mapping>
<servlet-name>DescriptorServlet</servlet-name>
 <url-pattern>/rest/*/*/descriptor</url-pattern>
</servlet-mapping>

However, a URL like /rest/foo/1/descriptor still goes into the fooServlet
and not the DescriptorServlet giving a 404 error.

Does the servlet named "Jersey" intercepts all the calls to "/rest/*" even
though a more specific servlet is defined to handle "/rest/*/*/descriptor".

Or am i doing something wrong?

Thank you

Rahul