Java examples for javax.servlet.http:HttpSession
servlet is session id Expired
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; public class Main{ public static boolean isExpired(HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession sess = request.getSession(false); String sessId = null;//from ww w . ja va2 s . c o m if (sess != null) { sessId = sess.getId(); } else { //Fix: for those browsers not supporting cookies sessId = request.getHeader("JSESSIONID"); response.setHeader("Set-Cookie", "JSESSIONID=" + sessId); } if (!SessionListener.isAlive(sessId)) { response.setStatus(401); response.getWriter().write("Session expired"); response.flushBuffer(); return true; } return false; } }