Ok,

I have been playing about with cactus for the last few days, and am
hitting problems trying to test servlets that forward or include another
resource.

Specifically when trying to test a "action" type servlet ("Model 2
stylee") that forwards to a JSP.

I am getting a ClassCastException and I think the following is the
problem: 

in the servlet i have the following line of code:

request.getRequestDispatcher(somePageIdentifier).forward(request,
response);

This makes the test framework barf.

Why?
In HttpServletRequestWrapper the following call returns the ACTUAL
requestdispatcher rather than a wrapped version.

   public RequestDispatcher getRequestDispatcher(String thePath)
    {
        return m_Request.getRequestDispatcher(thePath);
    }

which means that the following in RequestDispatcherWrapper is never
called:

    /**
     * Call the original <code>RequestDispatcher</code>
<code>forward()</code>
     * method but with the original HTTP request (not the simulation one
which
     * would make the servlet engine choke !).
     *
     * @param theRequest the simulation HTTP request
     * @param theResponse the original HTTP response
     */
    public void forward(ServletRequest theRequest, ServletResponse
theResponse) throws IOException, ServletException
    {
        HttpServletRequestWrapper request =
(HttpServletRequestWrapper)theRequest;
        m_OriginalDispatcher.forward(request.getOriginalRequest(),
theResponse);
    }

Note the comment... 

I have tested the HttpServletRequestWrapper with the following:
   public RequestDispatcher getRequestDispatcher(String thePath)
    {
        return new RequestDispatcherWrapper(
m_Request.getRequestDispatcher(thePath));
    }

which seems to work and allows my original code to forward to the jsp as
per before trying cactus.

Anyone confirm this as a bug?

and if so how do i get this fix submitted back into cactus?
Do I need to do a diff to show the change or is the above enough?

Jari

--
Jari Worsley
Senior Programmer
Hyperlink Interactive Ltd

Reply via email to