1 16 17 package org.apache.tester; 18 19 20 import java.io.*; 21 import javax.servlet.*; 22 import javax.servlet.http.*; 23 24 35 36 public class Forward03 extends HttpServlet { 37 38 39 public void doGet(HttpServletRequest request, HttpServletResponse response) 40 throws IOException, ServletException { 41 42 StringBuffer sb = new StringBuffer (); 44 response.setContentType("text/plain"); 45 PrintWriter writer = response.getWriter(); 46 47 String path = request.getParameter("path"); 49 if (path == null) 50 path = "/Forward03a"; 51 52 request.setAttribute("Forward03", "This is the forwarded attribute"); 54 if (request.getAttribute("Forward03") == null) 55 sb.append(" Cannot retrieve attribute to forward/"); 56 57 RequestDispatcher rd = 59 getServletContext().getRequestDispatcher(path); 60 if (rd == null) { 61 sb.append(" No RequestDispatcher returned/"); 62 } else { 63 if (sb.length() < 1) 64 rd.forward(request, response); 65 } 66 67 if (sb.length() >= 1) { 69 writer.print("Include03 FAILED -"); 70 writer.println(sb.toString()); 71 while (true) { 72 String message = StaticLogger.read(); 73 if (message == null) 74 break; 75 writer.println(message); 76 } 77 } 78 StaticLogger.reset(); 79 80 } 81 82 } 83 | Popular Tags |