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 Forward03a extends HttpServlet { 37 38 private static final String specials[] = 39 { "javax.servlet.include.request_uri", 40 "javax.servlet.include.context_path", 41 "javax.servlet.include.servlet_path", 42 "javax.servlet.include.path_info", 43 "javax.servlet.include.query_string" }; 44 45 46 public void doGet(HttpServletRequest request, HttpServletResponse response) 47 throws IOException, ServletException { 48 49 StringBuffer sb = new StringBuffer (); 51 response.setContentType("text/plain"); 52 PrintWriter writer = response.getWriter(); 53 54 if (request.getAttribute("Forward03") == null) 56 sb.append(" Cannot retrieve forwarded attribute/"); 57 58 request.setAttribute("Forward03a", "This is our own attribute"); 60 if (request.getAttribute("Forward03a") == null) 61 sb.append(" Cannot retrieve our own attribute"); 62 63 for (int i = 0; i < specials.length; i++) { 65 if (request.getAttribute(specials[i]) != null) { 66 sb.append(" Returned attribute "); 67 sb.append(specials[i]); 68 sb.append("/"); 69 } 70 } 71 72 if (sb.length() < 1) 74 writer.println("Forward03 PASSED"); 75 else { 76 writer.print("Forward03 FAILED -"); 77 writer.println(sb.toString()); 78 } 79 80 while (true) { 81 String message = StaticLogger.read(); 82 if (message == null) 83 break; 84 writer.println(message); 85 } 86 StaticLogger.reset(); 87 88 } 89 90 } 91 | Popular Tags |