main.jsp
<body>
欢迎你 ${loginUsername} <a href="${pageContext.request.contextPath}/LogoutServlet">注销</a>
</body>
LogoutServlet
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.getSession().invalidate();
response.sendRedirect(request.getContextPath()+"/index.jsp");
}