I'm working on system which will allow users to create workspaces.After workspace creation user may login by providing username, password and workspace. And i need jsessionid generated after login to create connection between workspace and jsessionid.
Login goes thru REST.
@POST
@Path("login")
@Produces(ContentType.APPLICATION_JSON_CHARSET_UTF_8)
public JsonObject login(LoginCredentials loginCredentials) throws UnAuthorizedException {
//login logic
}
I also have interceptor implementing ContainerResponseFilter, WriterInterceptor.
@Override
public void filter(ContainerRequestContext requestContext, ContainerResponseContext context)throws IOException {
//...
}
how can i get generated jsessionid (which i see in response header)?
If you have a http request object you can get hold of the associated session. Once you've got the session you can get its id
request.getSession(true).getId()
Passing true
to getSession
causes a new session to be created if one does not already exist.