test
Форк от lirfrnk/test
1package servlets;
2
3import java.io.IOException;
4import java.io.PrintWriter;
5
6import javax.servlet.RequestDispatcher;
7import javax.servlet.ServletException;
8import javax.servlet.http.HttpServlet;
9import javax.servlet.http.HttpServletRequest;
10import javax.servlet.http.HttpServletResponse;
11
12import com.bittercode.constant.BookStoreConstants;
13import com.bittercode.service.UserService;
14import com.bittercode.service.impl.UserServiceImpl;
15
16public class LogoutServlet extends HttpServlet {
17
18UserService authService = new UserServiceImpl();
19
20public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
21PrintWriter pw = res.getWriter();
22res.setContentType(BookStoreConstants.CONTENT_TYPE_TEXT_HTML);
23try {
24
25boolean logout = authService.logout(req.getSession());
26
27RequestDispatcher rd = req.getRequestDispatcher("CustomerLogin.html");
28rd.include(req, res);
29// StoreUtil.setActiveTab(pw, "logout");
30if (logout) {
31pw.println("<table class=\"tab\"><tr><td>Successfully logged out!</td></tr></table>");
32}
33
34} catch (Exception e) {
35e.printStackTrace();
36}
37}
38
39}