Reputation: 6875
I have a webservice set up using CXF, JAX-RS and Spring. I have the following method:
@GET
@Path("/getPayload")
@Produces("application/XML")
public Response makePayload(){
Payload payload = new Payload();
payload.setUsersOnline(new Long(200));
return Response.ok().entity(payload).build();
}
How can I get access to the HttpRequest
object in my makePayload()
?
Will a call to this method generate a Session, and if so, can I get a handle to it and will that session be persistent for all subsequent requests from the same client?
Upvotes: 3
Views: 1887
Reputation: 570385
@Context
can be used to obtain contextual Java types related to the request or response:
@GET
@Path("/getPayload")
@Produces("application/XML")
public Response makePayload(@Context Request request) {
//...
}
Upvotes: 3