Gili wrote:
>
> Hi,
>
> What's the easiest way to construct the URI of a sub-resource? For
> example, say I have:
>
> /books/{id}/name
>
> @Path("books")
> class BooksResource
> {
> @Path("{id}")
> public BookResource getBook(...)
> {}
> }
>
> class BookResource
> {
> @Path("name")
> public BookNameResource getName(...)
> {}
> }
>
> class BookNameResource
> {
> public BookNameResource(Book book)
> {}
>
> @GET
> public String getBookName()
> {
> // I am here
> }
> }
>
> The only way I know of getting the URI inside
> BookNameResource.getBookName() is as follows:
> UriBuilder.fromResource(BooksResource.class).path(String.valueOf(book.getId())).path("name").build();
>
> This is obviously quite long and error-prone. Is there an easier way?
>
> Thank you,
> Gili
>
Nevermind, found it: javax.ws.rs.core.UriInfo.getRequestUri()
Thanks,
Gili
--
View this message in context: http://jersey.576304.n2.nabble.com/Getting-URI-of-sub-resources-tp6022364p6022392.html
Sent from the Jersey mailing list archive at Nabble.com.