1 16 17 package org.apache.tester; 18 19 20 import java.io.*; 21 import javax.servlet.*; 22 import javax.servlet.http.*; 23 24 25 34 35 public class Decoding01 extends HttpServlet { 36 37 public void doGet(HttpServletRequest request, HttpServletResponse response) 38 throws IOException, ServletException { 39 40 String desiredServlet = request.getParameter("servlet"); 42 String desiredPath = request.getParameter("path"); 43 44 response.setContentType("text/plain"); 46 PrintWriter writer = response.getWriter(); 47 StringBuffer results = new StringBuffer (); 48 49 String servletPath = request.getServletPath(); 51 if (desiredServlet == null) { 52 if (servletPath != null) 53 results.append(" servletPath is '" + servletPath + 54 "' instead of NULL/"); 55 } else { 56 if (servletPath == null) 57 results.append(" servletPath is NULL instead of '" + 58 desiredPath + "'/"); 59 else if (!servletPath.equals(desiredServlet)) 60 results.append(" servletPath is '" + servletPath + 61 "' instead of '" + desiredServlet + "'/"); 62 } 63 64 String pathInfo = request.getPathInfo(); 66 if (desiredPath == null) { 67 if (pathInfo != null) 68 results.append(" pathInfo is '" + pathInfo + 69 "' instead of NULL/"); 70 } else { 71 if (pathInfo == null) 72 results.append(" pathInfo is NULL instead of '" + 73 desiredPath + "'/"); 74 else if (!pathInfo.equals(desiredPath)) 75 results.append(" pathInfo is '" + pathInfo + 76 "' instead of '" + desiredPath + "'/"); 77 } 78 79 if (results.length() < 1) 81 writer.println("Decoding01 PASSED"); 82 else { 83 writer.print("Decoding01 FAILED -"); 84 writer.println(results.toString()); 85 } 86 87 while (true) { 89 String message = StaticLogger.read(); 90 if (message == null) 91 break; 92 writer.println(message); 93 } 94 StaticLogger.reset(); 95 96 } 97 98 } 99 | Popular Tags |