I have a JSF application but after a while I close the session but it gives me the following error and does not redirect to the login.
public String cerrarSession() {
SessionUtils.getSession().invalidate();
return "/login";
}
SessionUtils class
public class SessionUtils {
public static HttpSession getSession() {
return (HttpSession) FacesContext.getCurrentInstance()
.getExternalContext().getSession(false);
}
public static HttpServletRequest getRequest() {
return (HttpServletRequest) FacesContext.getCurrentInstance()
.getExternalContext().getRequest();
}
public static String getUserName() {
HttpSession session = (HttpSession) FacesContext.getCurrentInstance()
.getExternalContext().getSession(false);
return session.getAttribute("username").toString();
}
public static String getUserId() {
HttpSession session = getSession();
if (session != null) {
return (String) session.getAttribute("userid");
} else {
return null;
}
}
}
Severe: javax.faces.application.ViewExpiredException: viewId: ...
The view could not be restored ....