/* * @(#)Killer.java * * Copyright (c) 1998 Karl Moss. All Rights Reserved. * * You may study, use, modify, and distribute this software for any * purpose provided that this copyright notice appears in all copies. * * This software is provided WITHOUT WARRANTY either expressed or * implied. * * @author Karl Moss * @version 1.0 * @date 20Jan99 * */ package javaservlets.session; import javax.servlet.*; import javax.servlet.http.*; /** *
This servlet gathers all of the information about all of * the sessions and returns a formatted table as part of a * form. The user can then kill any of the sessions by * clicking a checkbox. This servlet on functions * prior to version 2.1 of the Servlet API */ public class Killer extends HttpServlet { /** *
Performs the HTTP GET operation * * @param req The request from the client * @param resp The response from the servlet */ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException { // Requesting more informatin about a particular // session? String info = req.getParameter("info"); if (info != null) { getInfo(info, req, resp); return; } // Set the content type of the response resp.setContentType("text/html"); // Force the browser not to cache resp.setHeader("Expires", "Tues, 01 Jan 1980 00:00:00 GMT"); // Get the PrintWriter to write the response java.io.PrintWriter out = resp.getWriter(); // Write the page header out.println(""); out.println("
"); out.println("Displays a page with detailed session info * @param id The session id * @param req The request from the client * @param resp The response from the servlet */ public void getInfo(String id, HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException { // Set the content type of the response resp.setContentType("text/html"); // Force the browser not to cache resp.setHeader("Expires", "Tues, 01 Jan 1980 00:00:00 GMT"); // Get the PrintWriter to write the response java.io.PrintWriter out = resp.getWriter(); // Write the page header out.println(""); out.println("
"); out.println("Creation Time | " + (new java.util.Date(creationTime)) + " | |
Last Access Time | " + (new java.util.Date(lastTime)) + " |
" + names[i] + " | " + curSession.getValue(names[i]) + " |
Initialize the servlet. This is called once when the * servlet is loaded. It is guaranteed to complete before any * requests are made to the servlet * * @param cfg Servlet configuration information */ public void init(ServletConfig cfg) throws ServletException { super.init(cfg); } /** *
Destroy the servlet. This is called once when the servlet * is unloaded. */ public void destroy() { super.destroy(); } }