users@jersey.java.net

Re: [Jersey] Serve Resources in Jersey Web-App

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 06 May 2009 22:34:37 +0200

Hi Robert,

It is possible to use the ServletContainer as a filter.

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.

[1] http://download.java.net/maven/2/com/sun/jersey/samples/bookstore/1.1.0-ea/bookstore-1.1.0-ea-project.zip

On May 6, 2009, at 6:14 PM, Robert Naczinski wrote:

> Hi,
>
> how I can serve resources in my Jersey web-app. In web.xml I have
> mapped ServletContainer to /*
>
> I mean: how make other files servable ( i.e. *.pdf or *.png or *.doc )
>
> Has enybody any ideeas?
>
> Regards,
>
> Robert
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>