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

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

java - SmsManager sending message more than one -