Is it possible to access the Request object in a REST method under JAX-RS?
I just found out
@Context Request request;
To elaborate on @dfa's answer for alternatives, I find this to be simpler than specifying the variable on each resource method signature:
public class MyResource {
@Context
private HttpServletRequest httpRequest;
@GET
public Response foo() {
httpRequest.getContentType(); //or whatever else you want to do with it
}
}
@Path
annotations are singletons, aren't they? Does that not mean that if your request takes long enough, eventually your thread will update with another requests metadata?