users@jersey.java.net

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

From: Ronak Patel <ronak2121_at_yahoo.com>
Date: Wed, 13 May 2009 14:19:45 -0700 (PDT)

Paul,

This web form allows me to integrate my JAX-RS Jersey application with our internal SSO solution.

I am also using Spring so I have the JAX-RS Spring servlet declared in my servlet mappings with /* as the url-pattern as you said.

This kind of url pattern prevents the login jsp from being mapped properly. Has anyone ever done this before? This is a common occurance in any enterprise.

Ronak


----- Original Message ----
From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
To: users_at_jersey.dev.java.net
Sent: Wednesday, May 13, 2009 1:20:27 PM
Subject: Re: [Jersey] web.xml url-pattern and @PathParam


On May 13, 2009, at 7:47 PM, Ronak Patel wrote:

> Paul,
>
> Thanks for your reply.
>
> My JSP page is a login page for J2EE security using the <login-config> element rather than a jsp that is part of the business logic of the application.
>
> How would you handle that? Would it be the same way as this below?
>

Yes, ensure that the regex matches the path for logging in.

Alternatively you can ensure that all your root resource classes have a unique path via the URL pattern declaration.

So a single declared pattern of:

  <url-pattern>/surface/*</url-pattern>

would mean that a root resource class say:

  @Path("abc")

would be served by the path:

  <web-context-path>/surface/abc

I am not sure how the login-config works, if it is filter based you might be able to declare it before the Jersey stuff, but i am not sure.

Paul.


> Ronak
>
> From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
> To: users_at_jersey.dev.java.net
> Sent: Wednesday, May 13, 2009 8:34:56 AM
> Subject: Re: [Jersey] web.xml url-pattern and @PathParam
>
> 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
>>
>
>
>


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