struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Hill" <andrew.david.h...@gridnode.com>
Subject RE: Newbie Q: Missing parameters with multipart/form-data
Date Fri, 13 Jun 2003 09:12:30 GMT
I havent really grokked what it is your doing here, but can share an insight
into multipart forms using struts that you probably already know and
probably wont help you - but maybe you can relate it to your situation?

HttpServletRequest parameters for multipart forms as provided by the servlet
api only include those values that are part of the request uri - form fields
are not included. Obviously this makes life a little difficult so struts (or
rather the commons file-upload) kindly parses the request to extract the
field values (and files) from whatever elwierdo format the browser submitted
them in and uses them to populate an object that 'wraps' the original
request. This populating is done just prior to the actionform being
populated (and only occurs if you have an action form!).

The wrapper is available throughout your action, however when you forward
from the action is is 'unwrapped' so forwarding is done using the original
request object (theres a bug in some 1.1 versions prior to b3 where this
didnt happen) as some containers dont like to forward on the wrapper - which
doesnt extend HttpServletRequestWrapper in order to stay compatible with
servlet api 2.2

Now in your case, as far as I can see from what you are saying, you are
repeating the *same* process 3 times, and the first two times it works, and
the third fails. What is different the third time? Can you explain the
problem better?

I can easily imagine something failing on the first or second try, but the
third... strange!

<snip>
This folderId parameter is added as a hidden input in the form on the
generated page. (upload.do?folderId=n)
</snip>
The "?folder=n" in the url is a url parameter thinghy not a hidden input -
so that statement seems a bit contradictory. Which is it you are using. As
explained above the difference can be significant for a multipart form.

Since the aim is to upload multiple files (one at a time?) I presume you are
using a session scoped action form?


-----Original Message-----
From: Chris Cooper [mailto:ChrisCooperStrutsList@hotmail.com]
Sent: Friday, 13 June 2003 16:54
To: Struts Users Mailing List
Subject: Re: Newbie Q: Missing parameters with multipart/form-data


No takers?


> Hi guys,
>
> I've had a good look through the archives (and in fact pretty much the
whole
> of Usenet!) and I find several mentions of my problem similar to my own,
but
> no solutions.
>
> Please bear with me and read "parameter" as "parameter/attribute", I still
> haven't quite got the distinction concrete in my mind as yet!
>
> The problem is as follows:
>
> 1. I have a form for uploading multiple files, initially the user GETs the
> page with the form, the URL for this form has a URL encoded parameter for
a
> target folderId in my database.  This folderId parameter is added as a
> hidden input in the form on the generated page. (upload.do?folderId=n)
>
> 2. The user selects a number of files to upload using:
>
> <form name="upload" action="upload.do" encoding="multipart/form-data">
>     <input type="file" name="uploadFile_n">
>     etc...
>     <input type="hidden" name="folderId" value="n"/>
>     Submit...
> </form>
>
> The user then hits the upload button to POST the form.
>
> 3. The UploadAction receives the POST request, processes each file and
sets
> the ForwardAction to the same page upload.do (my users may want to upload
> more files), the folderId is again added as a hidden input into the form,
> and the URL encoded parameter is now gone.
>
> 4. Step 2 happens again. Parameter folderId is still there in the form.
>
> 5. Step 3 happens again. Parameter folderId is still there attached to the
> request.
>
> 6. Step 2 happens again. Parameter folderId is *definitely* still there in
> the form, I have checked the HTML source!
>
> 7. Step 3 loses the plot, the getParameter("folderId") and
> getAttribute("folderId") both return null!  The parameter is no longer
> attached to the request nor are any of the file parameters present.
However
> the usual struts attributes are attached as expected.
>
> The form is very definitely being POSTed and the form definitely has the
> hidden input and the file inputs present, but at some point before my
> Action's performActionOnMultipartForm () method is being called, the
> parameters disappear into the Ether...
>
> I have reproduced this problem consistently, on reach occasion i upload
the
> same files (one each time) all three are JPEG images 500Kb, 1Mb and 2.1Mb
in
> size respectively, is the file size a problem?
>
> Frankly I am very confused, and would really appreciate any light that
> anyone can show on this, a solution would earn my undying gratitude :)
>
> Regards,
>
> Chris Cooper
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message