Greetings,

I'm not 100% sure of the protocol to follow when submitting a patch, so
please let me know if I'm screwing this up.

In ActionServlet.java, the processValidate method forwards the request back
to the input page if validation fails. The code in question looks like this:

RequestDispatcher rd = getServletContext().getRequestDispatcher(uri);
   if (rd == null) {
       response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                          internal.getMessage("requestDispatcher",
                                              uri));
       return (false);
   }

   rd.forward(request, response);
   return (false);

If the form is a multipart form, the process method wraps the request object
in a MultipartRequestWrapper. This causes a ClassCastException when the
servlet container (TomCat 3.2.2 in my case) tries to process the forward. I
was able to work around this problem with the following change to the
rd.forward(...) line:

if (request instanceof MultipartRequestWrapper) {
     rd.forward(((MultipartRequestWrapper)request).getRequest(),response);
}
else {
    rd.forward(request, response);
}

This will assure that the servlet container will get a request object that
is not already extended from HttpServletRequest. This cleared the problem up
for me on TomCat - I have not been able to test the patch on any other web
app servers.

This bug could be a real show stopper for anybody that's trying to verify
the validity of uploaded files, or additional form fields in the multipart
form.

Chad Johnston
[EMAIL PROTECTED]

Reply via email to