I’m using JSF2.0 with jsp.I’m trying to incorporate session invalidation in my project.I’ve tried using the following code.
<h:commandButton value="Logout" action="#{bean.logout}" </h:commandButton>
and my bean class contains the following method
public class Bean{
public String logout(){
FacesContext context = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession)context.getExternalContext().getSession(false);
session.invalidate();
return "login";
}
}
where string login redirects to login page.
my project has several pages which includes a header page..when i tried the above way…it was working fine when i click on logout from the very first page…If i try the same after going to other pages, its not logging out.Can anyone help me on this…is this the way we invalidate a session here???
UPDATE
I also tried using “*” in the navigation rule so that each page can be redirected to Login…but still the issue was same
Try
as outcome so the browser does not use the same request for the login-page, which has the session still active.