Question about request and session with CXF, JAX-RS web service

I have a web service configured 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 to access an object HttpRequestin mine makePayload()?

Will a call to this method generate a session, and if so, can I get a handle to it and will this session be constant for all subsequent requests from the same client?

+3
source share
1 answer

@Context can be used to get Java context types associated with a request or response:

@GET
@Path("/getPayload")
@Produces("application/XML")
public Response makePayload(@Context Request request) {
    //...
}
+3
source

Source: https://habr.com/ru/post/1732536/


All Articles