users@jersey.java.net

Re: [Jersey] Fixed <was> Re: [Jersey] Static references from JSP

From: James Strachan <james.strachan_at_gmail.com>
Date: Fri, 13 Feb 2009 16:31:33 +0000

Great - good idea!

2009/2/13 Paul Sandoz <Paul.Sandoz_at_sun.com>:
> Hi,
>
> I have committed this in the trunk.
>
> James, the fix is a little different to that which you proposed, in naming
> rather than in functionality. Strictly speaking it is not just about static
> content because we can also include JSPs too.
>
> Below you can find the web.xml for the bookstore sample that has been
> modified to use a filter.
>
> Paul.
>
> <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
> version="2.4">
>
> <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.feature.Redirect</param-name>
> <param-value>true</param-value>
> </init-param>
> <init-param>
>
> <param-name>com.sun.jersey.config.feature.ImplicitViewables</param-name>
> <param-value>true</param-value>
> </init-param>
> <init-param>
> <param-name>com.sun.jersey.config.property.packages</param-name>
>
> <param-value>com.sun.jersey.samples.bookstore.resources</param-value>
> </init-param>
> <init-param>
>
> <param-name>com.sun.jersey.config.property.WebPageContentRegex</param-name>
> <param-value>/(images|css|jsp)/.*</param-value>
> </init-param>
> </filter>
> <filter-mapping>
> <filter-name>Jersey Filter</filter-name>
> <url-pattern>/*</url-pattern>
> </filter-mapping>
> </web-app>
>
> On Feb 10, 2009, at 5:24 PM, James Strachan wrote:
>
>> 2009/1/31 sarat.pediredla <sarat.pediredla_at_gmail.com>:
>>>
>>> Hi all,
>>>
>>> Just to add to this thread and get some clarification.
>>>
>>> Is the bottom line now that I cannot use Jersey with static resources? I
>>> was
>>> hoping to replace Struts 2 (which I mainly use for MVC rather than the
>>> extraneous stuff) with Jersey in a new project and consider my dismay
>>> when I
>>> realised that if I set Jersey to map to /* then I could not serve ANY
>>> static
>>> resources.
>>>
>>> In Struts 2, all I had to do was add a filter before the Struts 2 filter
>>> to
>>> just forward to the static resource (JS, CSS, Image) etc.
>>
>> Yeah that approach should work with Jersey too
>>
>>
>>> With Jersey using a servet in web.xml I figured this is not possible at
>>> all.
>>>
>>> In summary, is there an easy way to have Jersey as my "main" web
>>> framework
>>> and have it handle (or not handle and just pass through to Tomcat),
>>> requests
>>> for *.js , *.css etc?
>>
>> There's a patch here
>> https://jersey.dev.java.net/issues/show_bug.cgi?id=208
>>
>> which builds on Paul's servlet filter work to add a regex property to
>> the servlet filter so you can configure what servlet paths are static
>> content and let your web container serve those up. I wonder if you
>> could try that patch out on your web application and see if it does
>> the trick?
>>
>> If you apply the patch you'll see the bookstore example serves up some
>> static content (/css/style.css) and see the use of the regex in the
>> web.xml
>>
>> --
>> James
>> -------
>> http://macstrac.blogspot.com/
>>
>> Open Source Integration
>> http://fusesource.com/
>>
>> ---------------------------------------------------------------------
>> 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
>
>



-- 
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://fusesource.com/