Jon Belinfante wrote:
> 
> I have a Servlet method that as follows that is meant to do no more then forward
> to a test JSP page called WibbleWobble
I've had this before - it's a bug in Cactus and I thought this had been
fixed.

It's a bug in the HttpServletRequestWrapper:

I posted an earlier message about this, but not sure it's been fixed:

In a 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));
    }

So the wrapper needs to return the wrapped version of the
requestDispatcher, not the actual requestdispatcher. This is
why your code is barfing.


Jari


--
Jari Worsley
Senior Programmer
Hyperlink Interactive Ltd

Reply via email to