Ahhh.
Multipart requests are funny beasts. They dont work the same way as normal
requests.

In a normal request the servlet container will parse the request and
initialise the request parameters in the request object (which you can then
obtain through such calls as request.getParameter("bob")....).

Multipart requests however are submitted a different way to normal requests.
The servlet container is too "stuck up" to associate with such working-class
request types (something to do with the format being merely an RFC and not
an official standard or some such bourgeious nonsense) and so for a
multipart request, getParameter() will return null!!!

This is where struts comes in. Struts is much nicer than your average
servlet container, and it provides special support for multipart requests to
help make them act like normal requests for most purposes. (Well actually I
think its in some commons project now that struts leverages off - but the
origin of this code was actually in struts so I'll just lump it all in
together as "Struts" for the purposes of this discussion).

When a multipart request is submitted the request parameters arent
initialised by your servlet container. Struts will create a RequestWrapper
object to wrap the request and it will read from the requests input stream
and initialise the parameters in this RequestWrapper object. (It will also
read the files being uploaded and create the FormFile objects for the file
fields if there are any). The request object that gets passed to your action
is thus in fact this Multipart request wrapper object created by struts.
(You can verify this by comparing the results of a
request.getClass().getName() call for a multipart and non-multipart request
sent to your action).

When the action has finished processing the request processor will "unwrap"
the request wrapper it created and forward based on the original request
object.

Now what I think is happening to you here (and Im not 100% sure) is that
when the second action is hit, the input stream for the request has been
read already and cannot be re-read - and thus the multipart request cant be
processed a second time. Your best bet for a workaround is to do something
like what you were doing before - store a reference to the actionform
populated for the first request and look this up in the second.

hth
Andrew



-----Original Message-----
From: Caroline Lauferon [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 19 November 2003 18:32
To: [EMAIL PROTECTED]; Struts Users Mailing List
Subject: Re: chained actions


> Is it a multipart form (file upload)?
yes..... and since you asked me, I just changed it..... and now it works???
(but the reset method is called between the two action in both cases). I
don't need this encoding, but I wanted to always use the same skeleton,
that's why i used it.
can you explain me what has been happening?


Caroline, puzzled


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to