struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benjamin Cox <>
Subject Re: MultipartRequestWrapper and HttpServletRequest parameters
Date Sat, 16 Aug 2003 18:38:53 GMT
Struts-Users group:  Please see below for our original issue... sorry to 
cross-post this one, but I wasn't sure we did the right thing by posting 
to struts-dev in the first place.  Will someone set us straight?

Gaining more information on this issue:  we tried to subclass 
RequestProcessor and refrain from unwrapping the original 
HttpServletRequest in the doForward() method before forwarding the 
request along.  However, there are other places where the original 
HttpServletRequest is retrieved, such as in 

It is when this ParameterTag tries to retrieve the parameters from the 
HttpServletRequest that an exception is thrown.  It retrieves its 
HttpServletRequest directly from the javax.servlet.jsp.PageContext.  The 
required parameter "returnto" is not found in this request, since all 
parameters were parsed into the MultipartRequestWrapper, which 
presumably cannot replace the request contained in the PageContext.

We've noticed a lot of documentation in the source around this issue 
which seems to indicate that a move to the Servlet 2.3 specification 
will cause MultipartRequestWrapper to play a little more nicely with the 
J2EE spec.  Once this happens, MultipartRequestWrapper will apparently 
be changed into a subclass of HttpServletRequestWrapper. 

Will this change will result in the MultipartRequestWrapper being 
returned from the J2EE spec methods which currently return the 

If so, when do we anticipate the move to Servlet 2.3?


  Ben && Tim

Benjamin Cox wrote:

> Hello all,
> We are having some trouble with multipart uploads and validation.  A 
> similar problem was described in: 

> Our problem is an attempt to validate a form that includes a file 
> upload.  Our ActionForm successfully returns the correct set of 
> ActionErrors when a field is missing, but then provides the following 
> exception when it tries to display the form again ('returnto' is one 
> of our hidden form fields):  
> javax.servlet.jsp.JspException: No parameter returnto was included in 
> this request
> We've traced through the source code and determined that a 
> MultipartRequestWrapper is being created around our HttpServletRequest 
> when we perform a file upload via multipart/form-data.  This 
> MultipartRequestWrapper, while it contains the original 
> HttpServletRequest, handles parsing and storing of the request 
> parameters on its own.  This is helpful, indeed, except that when the 
> RequestProcessor forwards the request to another action (such as after 
> validation), it does not forward the MultipartRequestWrapper, but the 
> original HttpServletRequest, which was never populated with any 
> parameters!
> The original, never-populated HttpServletRequest is unwrapped on line 
> 1058-1060 of org.apache.struts.action.RequestProcessor, and forwarded 
> on the chain via RequestDispatcher.forward().  Naturally, this causes 
> the next step in the chain (sending back a form with errors) to fail, 
> since it relies on the missing parameters to populate the form fields.
> Our current workaround is to utilize JavaScript to append the request 
> parameters to the form action string before submitting it, but we'd 
> prefer for the HttpServletRequest to be populated, if at all possible.
> Though the J2EE spec does not indicate setParameter() as one of its 
> methods, does anyone know if there is any way "behind the scenes" to 
> get this request object populated?  Or, would it be possible to pass 
> the MultipartRequestWrapper back as-is?
> Thanks for any insight,
>  Ben Cox (&& Tim Ruppert)
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message