views:

147

answers:

1

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?

+1  A: 

@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) {
    //...
}
Pascal Thivent
Thank you. I will try that. You Rock.