1 16 17 package org.apache.tester; 18 19 20 import java.io.*; 21 import java.util.*; 22 import javax.servlet.*; 23 import javax.servlet.http.*; 24 25 26 32 33 public class Redirect01 extends HttpServlet { 34 35 36 38 39 48 public void doGet(HttpServletRequest request, 49 HttpServletResponse response) 50 throws IOException, ServletException { 51 52 response.setContentType("text/plain"); 53 PrintWriter writer = response.getWriter(); 54 55 try { 56 response.sendRedirect(request.getContextPath() + "/Redirect01a"); 57 return; 58 } catch (IllegalStateException e) { 59 writer.println("Redirect01 FAILED - Threw IllegaStateException"); 60 e.printStackTrace(writer); 61 } 62 try { 63 writer.println("Redirect01 FAILED - Output text after redirect"); 64 } catch (Throwable t) { 65 throw new ServletException("Redirect01 Post-Redirect Output Error", 66 t); 67 } 68 while (true) { 69 String message = StaticLogger.read(); 70 if (message == null) 71 break; 72 writer.println(message); 73 } 74 StaticLogger.reset(); 75 76 } 77 78 79 } 80 | Popular Tags |