Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ePhoneShop/src/main/java/com/xpacer/webai/servlets/customer/LogoutServlet.java
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
70 lines (61 sloc)
2.21 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package com.xpacer.webai.servlets.customer; | |
import com.xpacer.webai.utils.ShopperUtils; | |
import java.io.IOException; | |
import javax.servlet.ServletException; | |
import javax.servlet.annotation.WebServlet; | |
import javax.servlet.http.HttpServlet; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; | |
import javax.servlet.http.HttpSession; | |
/** | |
* | |
* @author xpacer | |
*/ | |
@WebServlet(name = "CustomerLogoutServlet", urlPatterns = {"/customer/logout"}) | |
public class LogoutServlet extends HttpServlet { | |
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code."> | |
/** | |
* Handles the HTTP <code>GET</code> method. | |
* | |
* @param request servlet request | |
* @param response servlet response | |
* @throws ServletException if a servlet-specific error occurs | |
* @throws IOException if an I/O error occurs | |
*/ | |
@Override | |
protected void doGet(HttpServletRequest request, HttpServletResponse response) | |
throws ServletException, IOException { | |
HttpSession session = request.getSession(); | |
ShopperUtils.storeSessionUser(session, null); | |
ShopperUtils.storeSessionCartCount(session, 0); | |
ShopperUtils.storeSessionCartTotal(session, 0); | |
request.changeSessionId(); | |
response.sendRedirect(request.getContextPath() + "/customer/home"); | |
} | |
/** | |
* Handles the HTTP <code>POST</code> method. | |
* | |
* @param request servlet request | |
* @param response servlet response | |
* @throws ServletException if a servlet-specific error occurs | |
* @throws IOException if an I/O error occurs | |
*/ | |
@Override | |
protected void doPost(HttpServletRequest request, HttpServletResponse response) | |
throws ServletException, IOException { | |
} | |
/** | |
* Returns a short description of the servlet. | |
* | |
* @return a String containing servlet description | |
*/ | |
@Override | |
public String getServletInfo() { | |
return "Logout servlet"; | |
}// </editor-fold> | |
} |