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 44 public class CheckServlet extends AbstractServlet { 45 46 49 private static final long serialVersionUID = 1L; 50 51 58 public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException , IOException { 59 60 HttpSession session = req.getSession(false); 61 62 String sessionCheckInfo = "JSESSIONID cookie absent."; 63 Cookie [] cookies = req.getCookies(); 64 if (cookies != null) { 65 for (int i = 0; i < cookies.length; i++) { 66 if (cookies[i].getName().equals("JSESSIONID")) { 67 sessionCheckInfo = "JSESSIONID cookie present."; 68 } 69 } 70 } 71 72 getLogger().log(BasicLevel.INFO, sessionCheckInfo); 73 req.setAttribute("sessionCheckInfo", sessionCheckInfo); 74 75 RequestDispatcher disp = req.getRequestDispatcher("../jsp/checkRsp.jsp"); 79 disp.forward(req, res); 80 81 return; 82 } 83 } | Popular Tags |