vmassol 01/07/03 05:13:16
Modified: cactus/src/framework/servlet22/org/apache/commons/cactus/server
HttpServletRequestWrapper.java
cactus/src/framework/servlet23/org/apache/commons/cactus/server
HttpServletRequestWrapper.java
cactus/src/sample/share/org/apache/commons/cactus/sample/unit
TestServletTestCase2.java
Log:
fixed bug when calling ServletRequest.getRequestDispatcher(), it was not returning
the wrapped request dispatcher, leading to an error when forward() or include() were
used ...
Revision Changes Path
1.2 +9 -1
jakarta-commons/cactus/src/framework/servlet22/org/apache/commons/cactus/server/HttpServletRequestWrapper.java
Index: HttpServletRequestWrapper.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cactus/src/framework/servlet22/org/apache/commons/cactus/server/HttpServletRequestWrapper.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HttpServletRequestWrapper.java 2001/04/09 11:52:35 1.1
+++ HttpServletRequestWrapper.java 2001/07/03 12:12:58 1.2
@@ -386,9 +386,17 @@
return m_Request.getRequestedSessionId();
}
+ /**
+ * @return a wrapped request dispatcher instead of the real one, so that
+ * forward() and include() calls will use the wrapped dispatcher
+ * passing it the *original* request [this is needed for some
+ * servlet engine like Tomcat 3.x which do not support the new
+ * mechanism introduced by Servlet 2.3 Filters].
+ */
public RequestDispatcher getRequestDispatcher(String thePath)
{
- return m_Request.getRequestDispatcher(thePath);
+ return new RequestDispatcherWrapper(
+ m_Request.getRequestDispatcher(thePath));
}
public Cookie[] getCookies()
1.2 +9 -1
jakarta-commons/cactus/src/framework/servlet23/org/apache/commons/cactus/server/HttpServletRequestWrapper.java
Index: HttpServletRequestWrapper.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cactus/src/framework/servlet23/org/apache/commons/cactus/server/HttpServletRequestWrapper.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HttpServletRequestWrapper.java 2001/04/09 11:52:35 1.1
+++ HttpServletRequestWrapper.java 2001/07/03 12:13:05 1.2
@@ -319,9 +319,17 @@
return m_Request.getScheme();
}
+ /**
+ * @return a wrapped request dispatcher instead of the real one, so that
+ * forward() and include() calls will use the wrapped dispatcher
+ * passing it the *original* request [this is needed for some
+ * servlet engine like Tomcat 3.x which do not support the new
+ * mechanism introduced by Servlet 2.3 Filters].
+ */
public RequestDispatcher getRequestDispatcher(String thePath)
{
- return m_Request.getRequestDispatcher(thePath);
+ return new RequestDispatcherWrapper(
+ m_Request.getRequestDispatcher(thePath));
}
public String getRemoteHost()
1.5 +12 -0
jakarta-commons/cactus/src/sample/share/org/apache/commons/cactus/sample/unit/TestServletTestCase2.java
Index: TestServletTestCase2.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cactus/src/sample/share/org/apache/commons/cactus/sample/unit/TestServletTestCase2.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TestServletTestCase2.java 2001/06/27 20:45:08 1.4
+++ TestServletTestCase2.java 2001/07/03 12:13:12 1.5
@@ -392,4 +392,16 @@
fail("No cookie named 'testcookie' found");
}
+ //-------------------------------------------------------------------------
+
+ /**
+ * Verify that request.getRequestDispatcher() works properly and can include
+ * another page.
+ */
+ public void testGetRequestDispatcherFromRequest() throws ServletException,
IOException
+ {
+ RequestDispatcher rd = request.getRequestDispatcher("/test/test.jsp");
+ rd.include(request, response);
+ }
+
}