Gili
Gili

Reputation: 90023

Jersey: How to get the URI of a resource?

ResourceContext.matchResource(URI) allows me to convert a URI to a Resource, but how do I go from a Resource to its URI?

Upvotes: 4

Views: 3192

Answers (1)

Gili
Gili

Reputation: 90023

Answering my own question:

@Context UriInfo uriInfo;

public URI getUri()
{
  return uriInfo.getBaseUriBuilder().path(MyResource.class).build();
}

Upvotes: 11

Related Questions