costin 01/02/10 13:17:09 Modified: src/tests/webpages/WEB-INF test-tomcat.xml src/tests/webpages/WEB-INF/classes/params Params.java RDInclude.java ServletUtil.java Log: - Enhanced the printParam method to output a prefix. - Used that to test parameter ordering and saving in RequestDispatcher.include Revision Changes Path 1.17 +29 -3 jakarta-tomcat/src/tests/webpages/WEB-INF/test-tomcat.xml Index: test-tomcat.xml =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/tests/webpages/WEB-INF/test-tomcat.xml,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- test-tomcat.xml 2001/02/09 17:02:01 1.16 +++ test-tomcat.xml 2001/02/10 21:17:08 1.17 @@ -16,7 +16,7 @@ early tests. --> - <property name="revision" value="$Revision: 1.16 $" /> + <property name="revision" value="$Revision: 1.17 $" /> <property name="host" value="127.0.0.1" /> <property name="port" value="8080" /> <property name="outputType" value="text" /> @@ -162,9 +162,35 @@ <param name="a" value="b" type="POST" /> <param name="c" value="d" type="POST" /> </httpRequest> - <responseMatch match="a = [ x ]" /> + <responseMatch match="a = [ x , b ]" /> <responseMatch match="m = [ n ]"/> - <responseMatch match="c = [ dxx ]"/> + <responseMatch match="c = [ d ]"/> + </httpClient> + + <httpClient> + <comment>Ordering in RequestDispatcher.include</comment> + <httpRequest + path="/test/servlet/params.RDInclude" + method="POST"> + <param name="a" value="k" type="GET" /> + <param name="c" value="l" type="GET"/> + <param name="a" value="m" type="GET"/> + </httpRequest> + <responseMatch match="before:a = [ k , m ]" /> + <responseMatch match="before:c = [ l ]" /> + <responseMatch + match="Calling RD.include for: params.Params/include1?a=b"/> + <responseMatch match="/include1:a = [ b , k , m ]" /> + <responseMatch match="/include1:c = [ l ]" /> + <responseMatch match="postInclude1:a = [ k , m ]" /> + <responseMatch match="postInclude1:c = [ l ]" /> + <responseMatch + match="Calling RD.include for: params.Params/include2?a=c&d=e"/> + <responseMatch match="/include2:a = [ c , k , m ]" /> + <responseMatch match="/include2:d = [ e ]" /> + <responseMatch match="/include2:c = [ l ]" /> + <responseMatch match="postInclude2:a = [ k , m ]" /> + <responseMatch match="postInclude2:c = [ l ]" /> </httpClient> 1.3 +8 -1 jakarta-tomcat/src/tests/webpages/WEB-INF/classes/params/Params.java Index: Params.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/tests/webpages/WEB-INF/classes/params/Params.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Params.java 2001/02/07 06:49:33 1.2 +++ Params.java 2001/02/10 21:17:09 1.3 @@ -18,7 +18,14 @@ response.setContentType("text/plain"); PrintWriter out = response.getWriter(); - ServletUtil.printParams( request, out ); + String pi=(String)request. + getAttribute( "javax.servlet.include.path_info"); + if( pi==null ) pi=""; + ServletUtil.printParamValues( "", " ]", + pi + ":", " = [ ", + "", "", + " , ", + request, out ); } } 1.2 +17 -7 jakarta-tomcat/src/tests/webpages/WEB-INF/classes/params/RDInclude.java Index: RDInclude.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/tests/webpages/WEB-INF/classes/params/RDInclude.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- RDInclude.java 2001/02/07 06:49:34 1.1 +++ RDInclude.java 2001/02/10 21:17:09 1.2 @@ -19,25 +19,35 @@ PrintWriter out = response.getWriter(); out.println("RequestDispatcher view: "); - ServletUtil.printParams( request, out ); + ServletUtil.printParamValues( "", " ]", + "before:", " = [ ", + "", "", + " , ", + request, out ); - String uri="Params?a=b"; + String uri="params.Params/include1?a=b"; out.println("Calling RD.include for: " + uri); RequestDispatcher rd=request.getRequestDispatcher(uri); rd.include( request, response ); - out.println("After include "); - ServletUtil.printParams( request, out ); + ServletUtil.printParamValues( "", " ]", + "postInclude1:", " = [ ", + "", "", + " , ", + request, out ); - uri="Params?a=c&d=e"; + uri="params.Params/include2?a=c&d=e"; out.println("Calling RD.include for: " + uri); rd=request.getRequestDispatcher(uri); rd.include( request, response ); - out.println("After include "); - ServletUtil.printParams( request, out ); + ServletUtil.printParamValues( "", " ]", + "postInclude2:", " = [ ", + "", "", + " , ", + request, out ); } } 1.2 +41 -9 jakarta-tomcat/src/tests/webpages/WEB-INF/classes/params/ServletUtil.java Index: ServletUtil.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/tests/webpages/WEB-INF/classes/params/ServletUtil.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ServletUtil.java 2001/02/07 06:49:34 1.1 +++ ServletUtil.java 2001/02/10 21:17:09 1.2 @@ -12,39 +12,71 @@ public class ServletUtil { - public static void printParams( HttpServletRequest request, + public static void printParams(HttpServletRequest request, PrintWriter out ) throws IOException, ServletException { + printParamNames( "Params = [", " ]"," , ",request, out ); + printParamValues( "", " ]", + "", " = [ " , + "", "", + " , ",request, out ); + out.println("Query = " + request.getQueryString()); + + } + + public static void printParamNames( String prefix, String sufix, + String sep, + HttpServletRequest request, + PrintWriter out ) + throws IOException, ServletException + { Enumeration paramN=request.getParameterNames(); - out.print( "Params = ["); + out.print( prefix ); while( paramN.hasMoreElements() ) { String name=(String)paramN.nextElement(); String all[]=request.getParameterValues(name); out.print(name); - if( paramN.hasMoreElements()) out.print(" , "); + if( paramN.hasMoreElements()) out.print( sep ); } - out.println( " ]"); + out.println( sufix ); + } - paramN=request.getParameterNames(); + + + public static void printParamValues( String prefix, + String sufix, + String prefixN, + String sufixN, + String prefixV, + String sufixV, + String sepV, + HttpServletRequest request, + PrintWriter out ) + throws IOException, ServletException + { + Enumeration paramN=request.getParameterNames(); + out.print( prefix ); while( paramN.hasMoreElements() ) { String name=(String)paramN.nextElement(); String all[]=request.getParameterValues(name); + out.print(prefixN); out.print(name); - out.print(" = [ " ); + out.print(sufixN ); for( int i=0; i<all.length; i++ ) { - if( i>0 ) out.print( " , "); + if( i>0 ) out.print( sepV ); + out.print( prefixV ); out.print( all[i] ); + out.print( sufixV ); } - out.println( " ]"); + out.println( sufix ); } - out.println("Query = " + request.getQueryString()); } public static void printBody( HttpServletRequest request, --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]