The source code of MaintainSessionPong.java: import java.io.* ; import javax.servlet.* ; import javax.servlet.http.* ; import java.util.* ; // for Date public class MaintainSessionPong extends HttpServlet { public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { doGet(request,response) ; } //doPost public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html") ; PrintWriter out = response.getWriter() ; Furniture.doHeader(out,"Maintain a session (Pong)") ; out.println("The session time-out is set to 60 seconds") ; HttpSession session = request.getSession() ; // Will create new session if none exists Integer accessCount = (Integer)session.getAttribute("accessCount") ; if (accessCount == null) { accessCount = new Integer(1) ; session.setMaxInactiveInterval(60) ; out.println("<p>Session starts:") ; } else { accessCount = new Integer(accessCount.intValue()+1) ; out.println("<p>Session continues:") ; } session.setAttribute("accessCount",accessCount) ; out.println("<p>Session ID : " + session.getId()) ; out.println("<br>Creation time : " + new Date(session.getCreationTime())) ; if (accessCount.intValue() > 1) { out.println("<br>Last access time : " + new Date(session.getLastAccessedTime())) ; out.println("<br>Number of accesses : " + accessCount) ; } // Now pass Ping's URL though encodeURL (to add URL rewriting for the session if necessary) String partnerURL = "MaintainSessionPing" ; String encoded = response.encodeURL(partnerURL) ; out.println("<p>Click <a href=\"" + encoded +"\">here</a> for Ping") ; // and Kill's URL partnerURL = "MaintainSessionKill" ; encoded = response.encodeURL(partnerURL) ; out.println("<p>Click <a href=\"" + encoded +"\">here</a> to kill the session") ; Furniture.doFooter(out) ; } // doGet } // class