package login;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/UserLogoutAction")
public class UserLogoutAction extends HttpServlet {
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String username = request.getParameter("username");
        UserInfo user = (UserInfo)request.getSession().getAttribute("user");
        if(user != null) {
            request.getSession().removeAttribute("user");
        }
        String path = request.getContextPath();
        response.sendRedirect(path+"/login/login.jsp");
    }
}
