users@jersey.java.net

Re: [Jersey] Jersey and url-pattern.

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 11 Feb 2010 09:40:15 +0100

Hi Damien,

When deployed to 1.0.3.1 what path served to the Translator resource:

   <context>/translate/translate

or

   <context>/translate

?


You can change the servlet URL pattern to:

   /translate/*

and then the path served to the Translator resource will be:

   <context>/translate/translate

If you change the @Path to @Path("/") the he path served to the
Translator resource will be

   <context>/translate/

If your intension is to retain the original @Path("translate") and
serve paths as follows:

   <context>/index.jsp
   <context>/translate

then you need to use a filter and configure the filter to "pass on"
JSP files:

    <filter>
        <filter-name>Jersey Filter</filter-name>
        <filter-
class>com.sun.jersey.spi.container.servlet.ServletContainer</filter-
class>
        <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-
name>
            <param-value>...</param-value>
        </init-param>
       <!-- filter paths using a regex if matched are not served by
Jersey -->
        <init-param>
            <param-
name>com.sun.jersey.config.property.WebPageContentRegex</param-name>
            <param-value>.*\.jsp</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>Jersey Filter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

Paul.



On Feb 10, 2010, at 3:01 PM, Damian Steer wrote:

> Hi,
>
> I recently moved my application from jersey 1.0.3.1 to 1.1.5, to
> remove the need for appengine hacks.
>
> I only have one resource:
>
> @Path("translate")
> public class Translator { ...
>
> My web.xml says:
>
> <servlet-mapping>
> <servlet-name>ServletAdaptor</servlet-name>
> <url-pattern>/translate</url-pattern>
> </servlet-mapping>
>
> (This is the jersey servlet container)
>
> In 1.0.3.1 that seemed to be fine. I could GET and POST to
> translate, but / routed to my index.html and all was well.
>
> In 1.1.5 /translate 404s. Changing url-pattern to /* works, but it
> breaks /. Is there a way to only pass /translate to jersey?
>
> Thanks in advance,
>
> Damian
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>