With given Application
@ApplicationPath("/api")
public class MyApplication {
}
UriInfo#getBaseUri gives me an application path.
@Context
private UriInfo uriInfo
uriInfo.getBaseUri(); // http://address/<context-path>/api
How can I get context-path?
How can I get full URL to context-path?
http://address/<context-path>
UPDATE
I currently using code from this answer.
@Context
private HttpServletRequest servletRequest;
final URI contextUri
= URI.create(servletRequest.getRequestURL().toString())
.resolve(servletRequest.getContextPath());
Any other suggestions?