users@jsr311.java.net

Re: trailing slash

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 06 Jan 2009 11:32:01 +0100

Hi Reto,

This was the point of the trailing slash functionality: to enable
automatic redirection if we choose to specify it.

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.

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
>