import javax.servlet.*; import javax.servlet.http.*; import java.io.*; /** * The SessionInfoServlet demonstrates the session management * mechanisms built into the servlet API. * * @author Dustin R. Callaway * @version 1.0, 06/06/98 */ public class SessionInfoServlet extends HttpServlet { /** * init method is called when servlet is first loaded. */ public void init(ServletConfig config) throws ServletException { super.init(config); //pass ServletConfig to parent } /** * service method builds an HTML document containing session * information and returns it to the client. */ public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //get current session or, if necessary, create a new one HttpSession mySession = request.getSession(true); //MIME type to return is HTML response.setContentType("text/html"); //get a handle to the output stream PrintWriter out = response.getWriter(); //generate HTML document out.println(""); out.println("
"); out.println("