java - Get application path with JAX-RS service -
i have jax-rs service want know application context path. before, using httpservletrequest application url, using these methods: public static string getapplicationbaseurl(httpservletrequest request) { return string.format("%s://%s:%s%s", request.getscheme(), request.getservername(), request.getserverport(), request.getcontextpath()); } i saw @context in jax-rs, returns paths beginning jax resource. can retrieve application path? i found answer. using @context javax.ws.rs.core.uriinfo class, but, can inject httpservletrequest too. so, can use getapplicationbaseurl method wrote.