struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Doug Padian" <>
Subject Multipart request losing parameters when forwarded
Date Tue, 17 Jun 2003 17:13:32 GMT
I can't seem to figure this one out.  My action class is getting a request coming from a form
that has the enctype of "multipart/form-data".  From looking in the JavaDocs, I see that what
ends up in the Action method is a MultipartRequestWrapper which wraps the HttpServletRequest.
 The Javadocs say that this wrapper exists within the action method, but once it gets forwarded,
it reverts back to the HttpServletRequest.  And that's where I have the problem.  Here's my
action method:

public ActionForward hold (
			ActionMapping mapping,
			ActionForm form,
			HttpServletRequest request,
			HttpServletResponse response) throws ServletException {
		log.debug("here in the hold() method");
		log.debug("The class passed in is: " + request.getClass().toString());
		log.debug("component key: " + request.getParameter("componentKey"));
		MultipartRequestWrapper wrapper = (MultipartRequestWrapper)request;
		HttpServletRequest req = wrapper.getRequest();
		log.debug("component key from http request: " + req.getParameter("componentKey"));
		ImageAsset asset = (ImageAsset)SessionDataContainer.getComponent(request);
		//FIXIT this is hardcoded for now
		AssetType assetType = AssetTypes.lookUpAssetTypeByExtension("gif");
		asset.setCreationDate(new Date());
		ActionForward forward = StrutsUtil.getForwardToMapping(request, mapping);
		log.debug("Action foward: " + forward.getName());
		String componentKey = request.getParameter("componentKey");
		req.setAttribute("componentKey", componentKey);
		request = req;
		return forward;

There is a lot of logging in there, but I am getting a certain parameter, "componentKey",
which I am getting out of the request, and that works fine.  The problem occurs when I forward
this onto another Struts action class.  In that class, it tries to access the same parameter
-- "componentKey" from the request, but it comes back empty.  I think this is happening because,
when the request gets forwarded on, it converts to a regular HttpServletRequest, and the parameter
is lost.  You can see in the method above, I'm trying to convert request back to an HttpServletRequest,
and then set the parameter as an attribute, but this doesn't work.

Any ideas on how to handle this?  I am using Struts 1.1 release candicate 1.  Thanks!!

-Doug Padian

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message