1,,页面:
<a href="${pageContext.request.contextPath }/logout">[退出]</a>
2,web.xml文件配置:
<servlet-mapping>
<servlet-name>OutRegistServlet</servlet-name>
<url-pattern>/logout</url-pattern>
</servlet-mapping>
3,OutRegistServlet :
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=gb2312");
request.getSession().invalidate();
response.sendRedirect("index.jsp");
}