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.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -