users@jersey.java.net

Re: [Jersey] Static references from JSP

From: James Strachan <james.strachan_at_gmail.com>
Date: Tue, 10 Feb 2009 16:24:10 +0000

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/