import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class SessionTimer extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,
IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
HttpSession session = req.getSession();
out.println("SessionTimer");
out.println("Session Timer
");
out.println("The previous timeout was " + session.getMaxInactiveInterval());
out.println("
");
session.setMaxInactiveInterval(2 * 60 * 60); // two hours
out.println("The newly assigned timeout is " + session.getMaxInactiveInterval());
out.println("");
}
}