dev@jersey.java.net

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

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Thu, 02 Aug 2007 16:55:36 -0400

See the path method of the new UriBuilder class in the 311 API

https://jsr311.dev.java.net/source/browse/jsr311/trunk/src/jsr311-api/
src/javax/ws/rs/core/UriBuilder.java?rev=64&view=markup

Its not yet implemented in Jersey but hopefully that will meet your
requirements when it is implemented. To do what you describe below
you'd write something like:

URI uri = UriBuilder.fromResource(SomeResource.class).path
(subResourcePath).build();

if SomeResource has a URI template of "foo" and subResourcePath is
"bar" then uri will be "foo/bar".

If you are in the resource for which you want to make a sub resource
URI you'll also be able to write

URI uri = uriInfo.getUriBuilder().path(subResourcePath).build();

since UriInfo know the current request URI.

Marc.

On Aug 2, 2007, at 4:21 PM, Peter Liu wrote:

> Hi Paul,
>
> Here is the context. Currently, when we generate the UriTemplate,
> we append it with "/".
> The reason is to make it easy for us to create an uri for a
> subresource from the parent
> uri by using the resolve() method since the resolve() strips off
> the last segment in the uri.
>
> So, the question is whether there is another simple way to achieve
> the same result
> without us having to append a "/".
>
> Thanks.
>
> Peter
>
> Nam Nguyen wrote:
>> Hi Paul,
>>
>> Could you please explain (again?) the reason for this
>> requirement. It seems to me this is just some temporary work-
>> around rather than be part of JSR specs.
>>
>> Thanks,
>>
>> -Nam
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: dev-help_at_jersey.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: dev-help_at_jersey.dev.java.net
>

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