CS506 Assignment No. 5 Solution
Wednesday, July 06, 2011 Posted In CS and IT Edit Thisimport java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class STimerOut extends HttpServlet {
// Handles the HTTP <code>GET</code> method.
// use rq to read incoming HTTP headers
// use rs to specify the HTTP response status
public void doGet(HttpServletRequest rq, HttpServletResponse rs)
throws ServletException, IOException {
// tell the browser that we are sending back html
rs.setContentType("text/html");
// used to modify println() statements to build a legal web page
PrintWriter out = rs.getWriter();
int t = 60;
/*
system extracts a user ID from a cookie or attached URL data, then uses
that as a key into a table of previously created HttpSession objects.
*/
HttpSession s = rq.getSession();
/*
following statements build a legal webpage
*/
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE >");
out.println("Session TimeOut ");
out.println("</TITLE>");
out.println("</HEAD>");
out.println("<BODY>");
out.println("<H1>");
out.println("Session TimeOut ");
out.println("</H1>");
out.println("gaining the old time out " +
s.getMaxInactiveInterval());/* getMaxInactiveInterval() gets the maximum
time in seconds for which the session remained
inactive.
out.println("<BR>");
out.println("<BR>");
s.setMaxInactiveInterval(2*t*t); /* sets the maximum time in seconds for which the
session can remain inactive.
out.println("giving new time to get out " +
s.getMaxInactiveInterval());
out.println("</BODY>");
out.println("</HTML>");