1 25 26 package org.objectweb.sampleCluster2.web; 27 28 import java.io.IOException ; 29 30 import javax.servlet.RequestDispatcher ; 31 import javax.servlet.ServletException ; 32 import javax.servlet.http.Cookie ; 33 import javax.servlet.http.HttpServletRequest ; 34 import javax.servlet.http.HttpServletResponse ; 35 import javax.servlet.http.HttpSession ; 36 37 import org.objectweb.util.monolog.api.BasicLevel; 38 39 42 public class ReleaseServlet extends AbstractServlet { 43 44 47 private static final long serialVersionUID = 1L; 48 49 56 public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException , IOException { 57 58 60 HttpSession session = req.getSession(false); 61 String sessionToReleaseInfo = "no session to invalidate"; 62 if (session != null) { 63 sessionToReleaseInfo = "session=" + session.getId() + " invalidated"; 64 session.invalidate(); 65 } 66 getLogger().log(BasicLevel.INFO, sessionToReleaseInfo); 67 req.setAttribute("sessionToReleaseInfo", sessionToReleaseInfo); 68 69 Cookie [] cookies = req.getCookies(); 70 if (cookies != null) { 71 Cookie ck = null; 72 for (int i = 0; i < cookies.length; i++) { 73 if (cookies[i].getName().equals("JSESSIONID")) { 74 ck = (Cookie ) cookies[i].clone(); 75 ck.setMaxAge(0); 76 res.addCookie(ck); 77 } 78 } 79 } 80 81 85 RequestDispatcher disp = req.getRequestDispatcher("../jsp/releaseRsp.jsp"); 86 disp.forward(req, res); 87 88 return; 89 } 90 } | Popular Tags |