FileDocCategorySizeDatePackage
HttpSessionInfoServlet.javaAPI DocExample1349Tue Apr 18 14:22:36 BST 2000None

HttpSessionInfoServlet

public class HttpSessionInfoServlet extends HttpServlet

Fields Summary
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)

	    HttpSession sess = req.getSession(true);
		resp.setContentType("text/html");
		PrintWriter out = new PrintWriter(resp.getOutputStream());

		out.println("<HTML>");
		out.println("<HEAD><TITLE>HttpSessionInfoServlet Output</TITLE></HEAD>");
		out.println("<BODY BGCOLOR=\"white\">");

		out.println("<H1>HttpSessionInfoServlet Output</H1>");
		out.println("<P>Session object = " + sess.toString());
		if (sess instanceof Serializable) {
		    out.println("<P>Hurrah! Session object IS serializable");
		} else {
		    out.println("<P>Session object NOT serializable");
		}
		out.println("<P>Getting some fields...!");
		Class c = sess.getClass();
		Field[] f = c.getDeclaredFields();
		out.println("<OL>");
		for (int i=0; i<f.length; i++)
		    out.println("<LI>" + f[i]);
		out.println("<P>All done!");
		out.println("</BODY>");
		out.println("</HTML>");
		out.close();
	
public java.lang.StringgetServletInfo()

		return "HttpSessionInfoServlet";
	
public voidinit(javax.servlet.ServletConfig config)

		super.init(config);