users@jersey.java.net

Re: [Jersey] how to serve jsp pages ?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 18 May 2009 09:50:52 +0200

On May 16, 2009, at 11:32 AM, Felipe Gaúcho wrote:

> simple task:
>
> to include an index.html in the helloworld-webapp example....
>
> how to ?
>
> I tried to include an index.html in the webapp folder, but I can't
> access it in the browser....... what I am missing?
>

The problem is the Jersey servlet with the URL pattern "/*" is
consuming the request.

There are three options:

1) Change the URL pattern of the Jersey servlet to be something
different that "/*" say "/blah/*".

2) Use the Jersey servlet as a filter and use a regex pattern to match
the path, which if matches Jersey will not
      process the request:

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

3) Create a resource to return the index.html view, for example:

   @Path("/)
   public class Foo {
     @GET
     Viewable getIndex() {
       return new Viewable("/index.html", null);
     }
   }

Paul.