I have a jsf web application which maintains the user session via a @SessionScoped Bean. And then I have a rest service to call a logout method which is used to invalidate the user's session.
However, when I call the rest service, the request.getSession() does not have the attributes set by the @SessionScoped bean. Also invalidating the session does not worked either.
When the @SessionScoped bean is called again, it's own session with the attributes are still available.
Do rest services create a separate session other than the faces session? If so how can I invalidate the session via a rest service (it has to be via a rest service not a managed bean or any faces cdi bean)
@Path("logout")
@RequestScoped
public class LogoutEndpoint {
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public boolean op( @Context final HttpServletRequest request) {
HttpSession httpSession = (HttpSession)request.getSession();
httpSession.invalidate();
}
}