JSP page still logged after logout

时间:2017-03-22 18:46:31

标签: java jsp

I have a problem in my project about JSP page.

When user logout, it redirected to the login page (until here its ok).

But, if user uses the browser "back" button, he can browse the "user_page" again. So, its like still "logged in".

I need a help to solve this. I already tried a lot of things since start looking for fix this.

Ps.: I noticed too that if user uses the browser "refresh" in "user_page" when back in it after logged out, the browser redirect it to login page normally and user will not able to back again.

This is the Logout.java code:

@WebServlet(name = "Logout", urlPatterns = {"/logout"})
public class Logout extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

       request.getSession().invalidate();
       response.sendRedirect(request.getContextPath()+"/");

    }
}

0 个答案:

没有答案