You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by rob <ro...@fastmail.fm> on 2002/04/18 14:47:33 UTC

multipart/form-data (bug?) or intended behavior?

It's been this way since struts 1.0 (and likely prior to) but http 
requests carrying multipart/form-data posts result in an exception being 
thrown if forwarded through more than one action.

(e.g request flow)

1 - submit multipart/form-data request (with at least one file input)
     request is forwarded to ActionOne.
2 - ActionOne handles multipart data, writes a file to disk does
     something with other parameters etc.  then forwards to ActionTwo.
3 - Exception is thrown.

This occurs in the following versions I've tested 1.0.x, 1.1-b1.  Copies
of the exceptions follow this post.

Workaround, never forward to a second action, always forward to a .jsp
which must be the end point for the request after the first action.
(This kind of sucks).

If this is a bug then consider it submitted, if it's designed this way
then how about changing it?  (pretty please?)

Thanks

Rob


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: multipart/form-data (bug?) or intended behavior?

Posted by "Adam P. Jenkins" <ad...@thejenkins.org>.
Well, in your example scenario, you said that ActionOne first saves the 
multipart data to a file, and then forwards to ActionTwo, so there's no 
problem.  When happens when a redirect forward is returned from an Action is 
as follows:

- Struts sees that the redirect property of the ActionForward is true, so 
instead of just calling the next action in the same request, it sends a 
response back to the browser.  The response contains a Redirect: header which 
contains the URL for ActionTwo.  The browser sees the Redirect header and so 
makes a request for ActionTwo, this time with no multipart/form-data.  The 
new request gets passed by struts directly to ActionTwo.  

Where the above would be a problem is if ActionOne did NOT handle the 
multipart data, but instead forwarded to ActionTwo expecting ActionTwo to 
handle the multipart data.  Since a redirect causes a new request to be made, 
any data in the current request is lost by the time ActionTwo gets called.  
But since in this case ActionOne already handled the request, there's no real 
problem.

Another example of where using a redirect forward is a problem is if your 
action saves some ActionMessages or ActionErrors in the request and then 
forwards, expecting the page being forwarded to to display the messages.  
Since ActionMessages are stored in the request object, if you returned a 
redirect forward from your action, the messages will be lost by the time the 
next page gets the request.

Adam

On Thursday 18 April 2002 01:14 pm, you wrote:
> Thats a pretty dirty workaround if your multipart request contained a
> 5MB file being uploaded.  Or what occurs in that case (when the browser
> makes the new request)?
>
> Rob
>
> Adam P. Jenkins wrote:
> > I believe another workaround is to set the redirect attribute on the
> > forward to true.  E.g. the action config for ActionOne would have a local
> > forward like this:
> >
> > <forward name="nextaction" path="/action2.do" redirect="true"/>
> >
> > Then in ActionOne, when you return mapping.findForward("nextaction"),
> > this will cause the struts to send a redirect header to the browser
> > telling it to make a new request for action2.  This works fine unless you
> > really wanted ActionTwo to have access to the same request attributes and
> > parameters as ActionOne.
> >
> > Adam
> >
> > On Thursday 18 April 2002 08:47 am, rob wrote:
> >>It's been this way since struts 1.0 (and likely prior to) but http
> >>requests carrying multipart/form-data posts result in an exception being
> >>thrown if forwarded through more than one action.
> >>
> >>(e.g request flow)
> >>
> >>1 - submit multipart/form-data request (with at least one file input)
> >>     request is forwarded to ActionOne.
> >>2 - ActionOne handles multipart data, writes a file to disk does
> >>     something with other parameters etc.  then forwards to ActionTwo.
> >>3 - Exception is thrown.
> >>
> >>This occurs in the following versions I've tested 1.0.x, 1.1-b1.  Copies
> >>of the exceptions follow this post.
> >>
> >>Workaround, never forward to a second action, always forward to a .jsp
> >>which must be the end point for the request after the first action.
> >>(This kind of sucks).
> >>
> >>If this is a bug then consider it submitted, if it's designed this way
> >>then how about changing it?  (pretty please?)
> >>
> >>Thanks
> >>
> >>Rob
> >
> > --
> > To unsubscribe, e-mail:  
> > <ma...@jakarta.apache.org> For additional
> > commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: multipart/form-data (bug?) or intended behavior?

Posted by rob <ro...@fastmail.fm>.
Thats a pretty dirty workaround if your multipart request contained a
5MB file being uploaded.  Or what occurs in that case (when the browser
makes the new request)?

Rob

Adam P. Jenkins wrote:
> I believe another workaround is to set the redirect attribute on the forward 
> to true.  E.g. the action config for ActionOne would have a local forward 
> like this:
> 
> <forward name="nextaction" path="/action2.do" redirect="true"/>
> 
> Then in ActionOne, when you return mapping.findForward("nextaction"), this 
> will cause the struts to send a redirect header to the browser telling it to 
> make a new request for action2.  This works fine unless you really wanted 
> ActionTwo to have access to the same request attributes and parameters as 
> ActionOne.
> 
> Adam
> 
> On Thursday 18 April 2002 08:47 am, rob wrote:
> 
>>It's been this way since struts 1.0 (and likely prior to) but http
>>requests carrying multipart/form-data posts result in an exception being
>>thrown if forwarded through more than one action.
>>
>>(e.g request flow)
>>
>>1 - submit multipart/form-data request (with at least one file input)
>>     request is forwarded to ActionOne.
>>2 - ActionOne handles multipart data, writes a file to disk does
>>     something with other parameters etc.  then forwards to ActionTwo.
>>3 - Exception is thrown.
>>
>>This occurs in the following versions I've tested 1.0.x, 1.1-b1.  Copies
>>of the exceptions follow this post.
>>
>>Workaround, never forward to a second action, always forward to a .jsp
>>which must be the end point for the request after the first action.
>>(This kind of sucks).
>>
>>If this is a bug then consider it submitted, if it's designed this way
>>then how about changing it?  (pretty please?)
>>
>>Thanks
>>
>>Rob
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: File Upload button label

Posted by Matt Raible <ma...@raibledesigns.com>.
Try searching the archives for the Users list in the future, but since
it's easy:

<html:submit>
<bean:message key="submit.label"/>
</html:submit>

You might be thinking for the "Browse" label on the <input type="file">
but that's not possible in the current HTML spec.

> -----Original Message-----
> From: Juan de Castro Paredes [mailto:jcastro@sgi.es] 
> Sent: Thursday, April 18, 2002 10:52 AM
> To: Struts Developers List
> Subject: File Upload button label
> 
> 
> Hi,
> 
>  Hi, does anybody know how to change the "Submit" label on 
> the Submit button?
> 
>  I have tried with:
> 
>      <html:file property="file" value="Go for it"/>
> 
>   but does not change the label at all...
> 
>  Thanx in advance,
> 
>  Juan
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:struts-dev-> unsubscribe@jakarta.apache.org>
> For 
> additional commands, 
> e-mail: <ma...@jakarta.apache.org>
> 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


File Upload button label

Posted by Juan de Castro Paredes <jc...@sgi.es>.
Hi,

 Hi, does anybody know how to change the "Submit" label on the Submit
button?

 I have tried with:

     <html:file property="file" value="Go for it"/>

  but does not change the label at all...

 Thanx in advance,

 Juan


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: multipart/form-data (bug?) or intended behavior?

Posted by "Adam P. Jenkins" <ad...@thejenkins.org>.
I believe another workaround is to set the redirect attribute on the forward 
to true.  E.g. the action config for ActionOne would have a local forward 
like this:

<forward name="nextaction" path="/action2.do" redirect="true"/>

Then in ActionOne, when you return mapping.findForward("nextaction"), this 
will cause the struts to send a redirect header to the browser telling it to 
make a new request for action2.  This works fine unless you really wanted 
ActionTwo to have access to the same request attributes and parameters as 
ActionOne.

Adam

On Thursday 18 April 2002 08:47 am, rob wrote:
> It's been this way since struts 1.0 (and likely prior to) but http
> requests carrying multipart/form-data posts result in an exception being
> thrown if forwarded through more than one action.
>
> (e.g request flow)
>
> 1 - submit multipart/form-data request (with at least one file input)
>      request is forwarded to ActionOne.
> 2 - ActionOne handles multipart data, writes a file to disk does
>      something with other parameters etc.  then forwards to ActionTwo.
> 3 - Exception is thrown.
>
> This occurs in the following versions I've tested 1.0.x, 1.1-b1.  Copies
> of the exceptions follow this post.
>
> Workaround, never forward to a second action, always forward to a .jsp
> which must be the end point for the request after the first action.
> (This kind of sucks).
>
> If this is a bug then consider it submitted, if it's designed this way
> then how about changing it?  (pretty please?)
>
> Thanks
>
> Rob

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: multipart/form-data (bug?) or intended behavior?

Posted by Matt Raible <ma...@raibledesigns.com>.
Rob, this is how it works pre-1.1.  1.1b1 has a bug in it and is not
even usable (for me).

In < 1.1 you have to add redirect="true" to your action forward to
forward to another action.  This is only when using the multi-part
request.  Search the archives for more information.

Matt

> -----Original Message-----
> From: Jens Viebig [mailto:jsurf@gmx.de] 
> Sent: Thursday, April 18, 2002 7:09 AM
> To: Struts Developers List; rob_mail@fastmail.fm
> Subject: Re: multipart/form-data (bug?) or intended behavior?
> 
> 
> I posted a Patch to this Mailing List a few days ago, but 
> nobody seems to be interested in it. I got an Error in 1.1b 
> even when i just forwarded a Multipart-Request to a 
> JSP-Page.It's a bug in the RequestProcessor
> doForward() Method. There the MultipartRequestWrapper must be 
> unwrapped to a normal HttpServletRequest-Object. See the patch
> 
> ----- Original Message -----
> From: "rob" <ro...@fastmail.fm>
> To: <st...@jakarta.apache.org>
> Sent: Thursday, April 18, 2002 2:47 PM
> Subject: multipart/form-data (bug?) or intended behavior?
> 
> 
> > It's been this way since struts 1.0 (and likely prior to) but http 
> > requests carrying multipart/form-data posts result in an exception 
> > being thrown if forwarded through more than one action.
> >
> > (e.g request flow)
> >
> > 1 - submit multipart/form-data request (with at least one 
> file input)
> >      request is forwarded to ActionOne.
> > 2 - ActionOne handles multipart data, writes a file to disk does
> >      something with other parameters etc.  then forwards to 
> ActionTwo. 
> > 3 - Exception is thrown.
> >
> > This occurs in the following versions I've tested 1.0.x, 1.1-b1.  
> > Copies of the exceptions follow this post.
> >
> > Workaround, never forward to a second action, always 
> forward to a .jsp 
> > which must be the end point for the request after the first action. 
> > (This kind of sucks).
> >
> > If this is a bug then consider it submitted, if it's 
> designed this way 
> > then how about changing it?  (pretty please?)
> >
> > Thanks
> >
> > Rob
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: multipart/form-data (bug?) or intended behavior?

Posted by Jens Viebig <js...@gmx.de>.
I posted a Patch to this Mailing List a few days ago, but nobody seems to be
interested in it. I got an Error in 1.1b even when i just forwarded a
Multipart-Request to a JSP-Page.It's a bug in the RequestProcessor
doForward() Method. There the MultipartRequestWrapper must be unwrapped to a
normal HttpServletRequest-Object. See the patch

----- Original Message -----
From: "rob" <ro...@fastmail.fm>
To: <st...@jakarta.apache.org>
Sent: Thursday, April 18, 2002 2:47 PM
Subject: multipart/form-data (bug?) or intended behavior?


> It's been this way since struts 1.0 (and likely prior to) but http
> requests carrying multipart/form-data posts result in an exception being
> thrown if forwarded through more than one action.
>
> (e.g request flow)
>
> 1 - submit multipart/form-data request (with at least one file input)
>      request is forwarded to ActionOne.
> 2 - ActionOne handles multipart data, writes a file to disk does
>      something with other parameters etc.  then forwards to ActionTwo.
> 3 - Exception is thrown.
>
> This occurs in the following versions I've tested 1.0.x, 1.1-b1.  Copies
> of the exceptions follow this post.
>
> Workaround, never forward to a second action, always forward to a .jsp
> which must be the end point for the request after the first action.
> (This kind of sucks).
>
> If this is a bug then consider it submitted, if it's designed this way
> then how about changing it?  (pretty please?)
>
> Thanks
>
> Rob
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>