1 退出页面修改

<li><cite></cite><a href="logout.do" target="rightFrame">退出登录</a><i></i></li>

跳转至logout.do

2 退出登录的servlet

/**
* 用户退出登录
*/
@WebServlet("/logout.do")
public class LogoutServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
this.doPost(req, resp);
}

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
HttpSession session = req.getSession();
session.invalidate();
resp.sendRedirect("login.jsp");
}
}

因为写了监听器,获得session销毁即可,不必要再去remove去session,直接销毁就可以了,然后调用监听器进行删除。