1 16 17 package org.apache.tester; 18 19 20 import java.io.*; 21 import javax.servlet.*; 22 import javax.servlet.http.*; 23 24 32 33 public class Session05 extends HttpServlet { 34 35 public void doGet(HttpServletRequest request, HttpServletResponse response) 36 throws IOException, ServletException { 37 38 StaticLogger.reset(); 40 41 HttpSession session = request.getSession(true); 43 session.setAttribute("attribute1", "value1"); 44 session.setAttribute("attribute1", "value2"); 45 session.removeAttribute("attribute1"); 46 session.removeAttribute("attribute2"); session.invalidate(); 48 49 response.setContentType("text/plain"); 51 PrintWriter writer = response.getWriter(); 52 while (true) { 53 String message = StaticLogger.read(); 54 if (message == null) 55 break; 56 writer.println(message); 57 } 58 StaticLogger.reset(); 59 60 } 61 62 } 63 | Popular Tags |