1 import java.io.IOException; 2 3 import javax.servlet.ServletException; 4 import javax.servlet.annotation.WebServlet; 5 import javax.servlet.http.HttpServlet; 6 import javax.servlet.http.HttpServletRequest; 7 import javax.servlet.http.HttpServletResponse; 8 import javax.servlet.http.HttpSession; 9 10 @WebServlet(urlPatterns = "/") 11 public class app extends HttpServlet 12 { 13 @Override 14 public void doGet(HttpServletRequest request, HttpServletResponse response) 15 throws IOException, ServletException 16 { 17 HttpSession s = request.getSession(); 18 19 if (s.isNew()) { 20 s.setMaxInactiveInterval(2); 21 } 22 23 response.addHeader("X-Session-Id", s.getId()); 24 response.addDateHeader("X-Session-Last-Access-Time", s.getLastAccessedTime()); 25 response.addIntHeader("X-Session-Interval", s.getMaxInactiveInterval()); 26 } 27 } 28