Hello,
I have seen a few references to this problem but have not seen any known
solution.  I have a scenario where I want to create a mock request/response
and forward that on using
servletContext.getRequestDispatcher(myJspPath).forward(req,
resp);  I have created FakeRequest and FakeResponse which implement
HttpServletRequest and HttpServletResponse respectively.  Using Tomcat
5.0.28 I was able to simply use these instances directly in may call to
forward. In upgrading to 5.5.19 I started to get a ClassCastException at
ApplicationDispatcher line 814.  I then found in the RequestDispatcher specs
for forward:
The request and response parameters must be either the same objects as were
passed to the calling servlet's service method or be subclasses of the
ServletRequestWrapper<http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletRequestWrapper.html>or
ServletResponseWrapper<http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletResponseWrapper.html>classes
that wrap them.

So I then wrapped these fake request/response objects in a
HttpServletRequestWrapper and HttpServletResponseWrapper but this has the
same results.  Am I reading the specs incorrectly?  Does the wrapper that I
use have to be, in this case, the tomcat specific wrapper that is used
internally?  If this is the case, is there any sort of work around that I
can use to get the intended results?

Any insight would be appreciated.
-Brandon

Reply via email to