users@jsr311.java.net

Re: trailing slash

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 06 Jan 2009 14:41:59 +0100

On Jan 6, 2009, at 1:59 PM, Reto Bachmann-Gmür wrote:

> Hi Paul
>>
>> This was the point of the trailing slash functionality: to enable
>> automatic redirection if we choose to specify it.
> Not sure what trailing slash functionality you're referring to.

The functionality for managing a trailing slash in the matching
algorithm.

>
>>
>> Jersey does this, it is turned off by default, and is enabled with a
>> Jersey specific feature. The reason it is turned off by default is
>> because automatic redirection tended to confuse developers.
> So if I'd like to develop an application as my example to run on any
> jax-rs container I would have to check the URI and do the
> redirection in
> the application code?
>

Yes.

Paul.

> Cheers,
> Reto
>>
>> Paul.
>>
>> On Jan 6, 2009, at 10:56 AM, Reto Bachmann-Gmür wrote:
>>
>>> according to section 3.7.3 a trailing slash in a Uri template is
>>> ignored. To be able to easily use generate relative link I think it
>>> would be better to have the implementation redirect to the
>>> location with
>>> trailing slash if the path contains one.
>>>
>>> Example
>>>
>>> @Path("my-app/")
>>> public class MyApp {
>>>
>>> @GET
>>> @Produces("text/html")
>>> public String getEntryPage() {
>>> return "<a href='subpage1'>subpage1</a><br><a
>>> href='subpage2'>subpage2</a>";
>>> }
>>>
>>> @Path("subpage1");
>>> public Response getSubPage1() {
>>> ...
>>> }
>>>
>>> @Path("subpage2");
>>> public Response getSubPage1() {
>>> ...
>>> }
>>>
>>> }
>>>
>>> The generated link in this application work when the entry page is
>>> invoked with a trailing slash but not when invoked without.
>>>
>>> Wouldn't it be nice if implementation would "canonicalize" the
>>> request
>>> uris by sending respective redirects?
>>>
>>> Cheers,
>>> Reto
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_jsr311.dev.java.net
>>> For additional commands, e-mail: users-help_at_jsr311.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jsr311.dev.java.net
>> For additional commands, e-mail: users-help_at_jsr311.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: users-help_at_jsr311.dev.java.net
>