You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Zhenlei Cai <ca...@fastmail.fm> on 2003/02/13 01:01:23 UTC

Jasper JSP forward infinite loop bug ?

Hi,

When I was using HttpUnit's ServletUnit and ServletRunner(webInfDir + 
"/web.xml","") to test a JSP (using Jasper as a mock object, no 
full-blown server), I found that Jasper's pageContext.forward() method 
was causing stack overflow because it "forwarded" to the original JSP 
itself, causing an infinite loop. I had to patch Jasper's source to make 
it work. Has any one else seen a similar problem? How did you address 
it? I was using Tomcat 4.1.18 source. My patch:


--- 
jakarta-tomcat-4.1.18-src/jasper/src/share/org/apache/jasper/runtime/PageContextImpl.java 
  2002-12-19 08:51:54.000000000 -0500
+++ /home/zcai/PageContextImpl.java     2003-02-12 18:03:42.000000000 -0500
@@ -422,6 +422,8 @@
         }

         String path = getAbsolutePathRelativeToContext(relativeUrlPath);
+        // zcai, remember we need to ask JspServlet to process the JSP 
page we are forwarding to, not the original one
+        request.setAttribute(org.apache.jasper.Constants.JSP_FILE, path);
         String includeUri
             = (String) request.getAttribute(Constants.INC_SERVLET_PATH);
         if (includeUri != null)



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org