1 16 17 package org.apache.tester; 18 19 20 import java.io.*; 21 import javax.servlet.*; 22 import javax.servlet.http.*; 23 24 30 31 public class Include10a extends HttpServlet { 32 33 private static final String specials[] = 34 { "javax.servlet.include.request_uri", 35 "javax.servlet.include.context_path", 36 "javax.servlet.include.servlet_path", 37 "javax.servlet.include.path_info", 38 "javax.servlet.include.query_string" }; 39 40 41 public void doGet(HttpServletRequest request, HttpServletResponse response) 42 throws IOException, ServletException { 43 44 StringBuffer sb = new StringBuffer (); 46 PrintWriter writer = response.getWriter(); 47 48 String value = null; 50 value = (String ) request.getAttribute("original.request_uri"); 51 if (!value.equals(request.getRequestURI())) 52 sb.append(" getRequestURI() is " + request.getRequestURI() + 53 " but should be " + value + "|"); 54 value = (String ) request.getAttribute("original.context_path"); 55 if (!value.equals(request.getContextPath())) 56 sb.append(" getContextPath() is " + request.getContextPath() + 57 " but should be " + value + "|"); 58 value = (String ) request.getAttribute("original.servlet_path"); 59 if (!value.equals(request.getServletPath())) 60 sb.append(" getServletPath() is " + request.getServletPath() + 61 " but should be " + value + "|"); 62 value = (String ) request.getAttribute("original.path_info"); 63 if (!value.equals(request.getPathInfo())) 64 sb.append(" getPathInfo() is " + request.getPathInfo() + 65 " but should be " + value + "|"); 66 value = (String ) request.getAttribute("original.query_string"); 67 if (!value.equals(request.getQueryString())) 68 sb.append(" getQueryString() is " + request.getQueryString() + 69 " but should be " + value + "|"); 70 71 value = (String ) 73 request.getAttribute("javax.servlet.include.request_uri"); 74 if (!(request.getContextPath() + "/Include10a/include/path").equals(value)) 75 sb.append(" request_uri is " + value + 76 " but should be " + request.getContextPath() + 77 "/Include10a/include/path|"); 78 value = (String ) 79 request.getAttribute("javax.servlet.include.context_path"); 80 if (!request.getContextPath().equals(value)) 81 sb.append(" context_path is " + value + 82 " but should be " + request.getContextPath() + "|"); 83 value = (String ) 84 request.getAttribute("javax.servlet.include.servlet_path"); 85 if (!"/Include10a".equals(value)) 86 sb.append(" servlet_path is " + value + 87 " but should be /Include10a|"); 88 value = (String ) 89 request.getAttribute("javax.servlet.include.path_info"); 90 if (!"/include/path".equals(value)) 91 sb.append(" path_info is " + value + 92 " but should be /include/path|"); 93 value = (String ) 94 request.getAttribute("javax.servlet.include.query_string"); 95 if (!"name2=value2".equals(value)) 96 sb.append(" query_string is " + value + 97 " but should be name2=value2|"); 98 99 if (sb.length() < 1) 101 writer.println("Include10a PASSED"); 102 else 103 writer.println("Include10a FAILED -" + sb.toString()); 104 105 } 106 107 } 108 | Popular Tags |