users@jersey.java.net

Re: [Jersey] web.xml url-pattern and _at_PathParam

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 13 May 2009 17:34:56 +0200

Hi Ronak,

Part of the problem might be the multiple declarations of URL pattern.
Why do you have multiple declarations?

Also, when you list the URLs are they relative URLs to the base say of
"/surface/" or "/weather/" ?

If you want to support JSPs and resource classes from the same base
URI then i recommend using the ServletContainer as a filter and
declare a regex pattern so that matching paths are not served by Jersey.

See the bookstore sample [1], specifically the web.xml

http://fisheye4.atlassian.com/browse/~raw,r=2009/jersey/trunk/jersey/
samples/bookstore/src/main/webapp/WEB-INF/web.xml

notice the init param:

  <init-param>
    <param-name>com.sun.jersey.config.property.WebPageContentRegex</
param-name>
    <param-value>/(images|css|jsp)/.*</param-value>
  </init-param>

that declares a regex to match against the request URL path. If the
regex matches then Jersey will pass the request on to the next filter
in the chain:

https://jersey.dev.java.net/nonav/apidocs/1.1.0-ea/jersey/com/sun/jersey/spi/container/servlet/ServletContainer.html
#PROPERTY_WEB_PAGE_CONTENT_REGEX

In the bookstore sample the regex matches directions that contain
images, CSS files, and JSP files.

Paul.

On May 13, 2009, at 12:03 PM, Ronak Patel wrote:

>
> Hi All,
>
> I'm using Jersey 1.0.3 and came across a weird problem.
>
> My web application is a mixture of a JSP page and the main REST web
> application.
>
> To accomodate both in the same web.xml, my web.xml structure for my
> REST web application is as follows:
>
> <servlet><display-name>sno</display-name><servlet-name>sno</servlet-
> name><servlet-class>com</servlet-class><load-on-startup>1</load-on-
> startup></servlet><servlet-mapping><servlet-name>sno</servlet-
> name><url-pattern>/forecast/*</url-pattern>
> <url-pattern>/surface/*</url-pattern>
> <url-pattern>/weather/*</url-pattern>
>
> Code as follows always results in an HTTP 404:
> @Controller_at_Path("/nation/{nationId}/")publicclassNationController
> {_at_GET@Produces("application/xml")publicResponse
> getNationByNationId( {_at_PathParam("nationId") finalLong nationId)}
> }
>
> All of the following URLs fail:
>
> /nation
> /nation/
> /nation/1
> /nation/1/
>
> I would assume all 4 of these URIs would work. Why doesn't Jersey
> match these uri properly?
>
> Ronak <url-pattern>/region/*</url-pattern></servlet-
> mapping>.sun.jersey.spi.spring.container.servlet.SpringServlet
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>