users@jersey.java.net

Re: [Jersey] Tomcat, trailing slashes and welcome files

From: Gregg Carrier <greggcarrier_at_gmail.com>
Date: Mon, 8 Mar 2010 08:59:00 -0800

Thanks Trolly and Paul -

That's a great solution. Works exactly as advertised.

Hopefully this thread can help someone else who runs into the same issue.
Thanks again.

Gregg

On Mon, Mar 8, 2010 at 2:24 AM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:

> Hi Gregg,
>
> As Trolly says configure Jersey using a filter.
>
> I dunno why there is a difference in behavior for "/" and "/*" servlet URL
> patterns. This also occurs for GlassFish that shares the same Tomcat code. I
> recommend not using "/" at all as i doubt it is portable.
>
> Paul.
>
>
> On Mar 6, 2010, at 2:03 AM, Gregg Carrier wrote:
>
> I know this is probably a Tomcat problem, but I'm hoping someone may have
>> run into this issue and can offer some advice.
>>
>> Desired behavior: I want all requests to my webapp to be handled by Jersey
>> except requests for index.jsp or the root of the webapp. I do not want
>> trailing slashes to be required in order to load URLs.
>>
>> The setups I have tried and the results:
>>
>> 1 - <servlet-mapping>
>> <servlet-name>Jersey Spring Web Application</servlet-name>
>> <url-pattern>/</url-pattern>
>> </servlet-mapping>
>>
>> <welcome-file-list>
>> <welcome-file>index.jsp</welcome-file>
>> </welcome-file-list>
>>
>> In this case, the index.jsp loads fine at /mywebapp/. The servlet handles
>> all other requests appropriately EXCEPT it requires a trailing slash at the
>> end of all URLs. Eg, /mywebapp/foo/ loads but /mywebapp/foo does not. This
>> setup would be perfect except for the trailing slash requirement. I want it
>> to load with or without the trailing slash.
>>
>> 2 - <servlet-mapping>
>> <servlet-name>Jersey Spring Web Application</servlet-name>
>> <url-pattern>/*</url-pattern>
>> </servlet-mapping>
>>
>> <welcome-file-list>
>> <welcome-file>index.jsp</welcome-file>
>> </welcome-file-list>
>>
>> With this setup the servlet handles requests with and without the trailing
>> slash (correctly). The index.jsp will not load at /mywebapp/ or
>> /mywebapp/index.jsp.
>>
>> Any ideas? Thanks very much!
>>
>> Gregg
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>