I am having a javax.servlet.Filter in which I want to redirect to login page if HttpSession is new and redirect to the logout page if HttpSession expired and to some other page if HttpSession is present.
The login and logout pages are external pages. My sample method is given below
@Override
public void doFilter(ServletRequest arg0, ServletResponse arg1,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) arg0;
HttpServletResponse response = (HttpServletResponse) arg1;
if (request.getSession(false) == null) {
response.sendRedirect("login page");
} else if (request.getRequestedSessionId() != null && !request.isRequestedSessionIdValid()) {
response.sendRedirect("logout page");
} else {
chain.doFilter(request, response);
}
}
The problem is after session expired, the logout page doesn't renders. How to get this to work?
Aucun commentaire:
Enregistrer un commentaire