users@jersey.java.net

Re: [Jersey] Static references from JSP

From: Julio Faerman <jfaerman_at_gmail.com>
Date: Mon, 26 Jan 2009 20:12:07 -0200

Perhaps the servlet (or future filter) could receive a "ignore"
pattern as a init-param, that when matched would delegate the request.

When we have this, plus the "form beans" and the error handling Craig
proposed some time ago, many web apps could use jersey without other
web frameworks, wich would be really great.

On Mon, Jan 26, 2009 at 7:20 PM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:
>
> On Jan 26, 2009, at 7:34 PM, jstrachan wrote:
>
>>
>>
>>
>> Paul Sandoz wrote:
>>>
>>>
>>> On Sep 2, 2008, at 8:46 AM, Paul Sandoz wrote:
>>>
>>>> On Sep 2, 2008, at 8:13 AM, Craig McClanahan wrote:
>>>>
>>>>> Paul Sandoz wrote:
>>>>>>
>>>>>> Julio Faerman wrote:
>>>>>>>
>>>>>>> I have tried to write out the resource, but this is troublesome
>>>>>>> as the
>>>>>>> resource is not on the classpath. I think there is a method to
>>>>>>> get web
>>>>>>> resources in servlet 2.5,
>>>>>>
>>>>>> You need to use methods on the ServletContext.
>>>>>>
>>>>>>
>>>>>>> but i also think that the forward should
>>>>>>> work.
>>>>>>
>>>>>> I cannot get it to :-( it works for JSPs, but not for "static"
>>>>>> stuff like HTML and images, perhaps it is bug in the GF servlet
>>>>>> implementation i am using?
>>>>>>
>>>>>>
>>>>> What servlet mappings do you have defined?
>>>>>
>>>>
>>>> "/" or "/*". I want to avoid a URL for the main application like:
>>>>
>>>> http://host:80/<deployment base>/<jersey base>
>>>>
>>>> and exposing out the other resources (static or JSP pages) explicitly.
>>>>
>>>> I can forward to JSPs but not to static content.
>>>>
>>>
>>> After more investigation
>>>
>>> - If the URL pattern is "/" then i can forward to JSPs but not to
>>> static content.
>>>
>>> - If the URL pattern is "/*" then i cannot forward to JSPs nor static
>>> content.
>>>
>>
>> I guess (as Craig says) folks can just map the Jersey servlet to those URL
>> patterns which folks know should only contain JAX-RS or implicit views.
>> e.g. /foo and /bar then leave /css/* /images/* and /js/* to be served up
>> by
>> the Servlet engines default servlet. Though that is a bit icky.
>>
>
> Agreed.
>
>
>> Its such a shame in the Servlet spec you can't kinda map specific URIs to
>> being static content. e.g. being able to say that /images/* /css/* and
>> /js/*
>> are static content so don't map them to Jersey's servlet would be great.
>>
>> Its a shame there's not a 'not' in the servlet mapping. I wonder if the
>> servlet spec should be updated to allow a true regex to be used for the
>> URL
>> mapping to make this kinda stuff easier?
>>
>> Basically if folks use JAX-RS as a web framework like
>> Struts/SpringMVC/Stripes et al - being able to easily serve up static
>> content for CSS/JavaScript/images (or regular JSP views outside of the
>> JAX-RS stuff) is gonna be key. So I think we need to figure out some best
>> practice for either
>>
>> (i) only mapping Jersey to specific URI patterns or
>> (ii) telling Jersey to exclude URIs and delegate to the default servlet
>>
>> Anyone else got any ideas of how to come up with a more generic best
>> practice for mixing and matching Jersey with static content & JSPs?
>
> Could this be supported by a servlet filter and processes the request before
> it hits the Jersey servlet, or could we support a Jersey filter (which we
> could develop if necessary) to manage forwarding to static pages/JSPs as
> required. I am not knowledgeable enough about the Servlet and Servlet filter
> details to know what is possible.
>
> In any case i really do agree we need to come up with a good solution.
>
> Paul.
>
>> --
>> View this message in context:
>> http://n2.nabble.com/Static-references-from-JSP-tp794843p2219723.html
>> Sent from the Jersey mailing list archive at Nabble.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
>
>