dev@jersey.java.net

Re: Ending '/' is required for UriTemplate value?

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Fri, 03 Aug 2007 13:49:01 -0400

On Aug 3, 2007, at 1:30 PM, Nam Nguyen wrote:
>>
>> Terminating a URI template with a '/' also has another function:
>> if the matching request URI does not terminate with a '/' then the
>> client is redirected to a request URI that terminates with a '/'.
> Could runtime implementation is such that UriTemplate("customers")
> and UriTemplate("customers/") identify the same resource?
>
> I think it would be confusing if we have:
> http://somehost/customers
> and:
> http://somehost/customers/
> locate 2 different things.
>
If you have a resource whose template is "customers/" and you don't
have one whose template is "customers" then both URIs will result in
the same resource - i.e. a request for "customers" will redirect to
"customers/". Conversely, if you have a resource whose template is
"customers" and you don't have one whose template is "customers/"
then a request for "customers/" will give you a 404, i.e. it won't
redirect to "customers".

The above is in line with the way lots of web sites work so hopefully
it will be fairly intuitive for developers.

Marc.

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.