You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Gary VanMatre <va...@wyantdata.com> on 2004/01/09 18:22:28 UTC

Seeking multipart-form advise

We are working on an application that has several pages that require
file upload capabilities.  Currently, our main tiles layout contains our
html form tag and we are considering adding the
enctype="multipart/form-data" attribute to the form tag in our main
layout but we are uncertain as to the overhead/cost of doing this.  
 
Is there a significant cost associated with making all forms multipart
in your web application?  Any experiences or insights would be greatly
appreciated.
 
Gary
 

Re: Seeking multipart-form advise

Posted by Brice Ruth <br...@fiskars.com>.
The extra work from the request processor isn't significant ... I had 
some problems with file upload/download, so ended up stepping through 
most of the code in a debugger, and it didn't seem like it was too bad. 
Just an 'off the cuff' comment :)

Gary VanMatre wrote:

>We are working on an application that has several pages that require
>file upload capabilities.  Currently, our main tiles layout contains our
>html form tag and we are considering adding the
>enctype="multipart/form-data" attribute to the form tag in our main
>layout but we are uncertain as to the overhead/cost of doing this.  
> 
>Is there a significant cost associated with making all forms multipart
>in your web application?  Any experiences or insights would be greatly
>appreciated.
> 
>Gary
> 
>
>  
>

-- 
Brice D. Ruth
Sr. IT Analyst
Fiskars Brands, Inc.


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


RE: Seeking multipart-form advise

Posted by Andrew Hill <an...@gridnode.com>.
Yes. There is some extra work done by the RP to parse the request. Im not
sure whether it will be significant or not in terms of performance, however
I can warn you that using multipart forms can sometimes have annoying side
effects. (However since you need to use multipart to allow uploads for some
of the forms anyway your still going to have to deal with them!)

The servlet API doesnt provide access via getParameter and setParameter to
parameters that are POSTed by a multipart form. (Though it seems that GET
style parameters as part of the url are parsed). To make life easier for you
when using multipart forms, struts will parse the request, create a wrapper
around the original request object. The wrapper's get and setParameter
methods will provide access to the request parameters as normal. This allows
multipart requests to be handled by your actions as though they were normal
requests however the abstraction isnt perfect.

This wrapper is not populated until the action form is populated (both
wrapper and form population are taken care of inside the static
RequestUtils.populate() method which is called from the RPs
processPopulate() method, which makes it a nusiance to try and modify this
behaviour). This has certain implications:

1. POSTed request parameters will not be available until after the form is
populated - which means that getParameter() calls will return null inside
the forms reset() method, and inside any RP methods you have overridden that
are called before population. (And in filters)

2. Struts 'unwraps' the MultipartRequestWrapper before forwarding (some
containers can't forward using it as it doesn't extend
HttpServletRequestWrapper (in order to allow struts to remain Servlet 2.2
compatible)). This means that after forwarding getParameter() will again be
returning nulls. (Furthermore I dont think you can reparse the request after
this, so if your doing 'Action Chaining' bad things can happen...)

Have you considered setting a flag in a request attribute to indicate that a
form uses uploads before forwarding to the view? Your main tile could check
this and use multipart only when necessary.

-----Original Message-----
From: Gary VanMatre [mailto:vanmatre@wyantdata.com]
Sent: Saturday, 10 January 2004 02:06
To: 'Struts Users Mailing List'
Subject: RE: Seeking multipart-form advise


I guess I should have been more specific, I was looking for advice as to
if the "enctype" attribute of the form tag introduces significant
overhead in struts.  I know that the struts request processor has to do
some extra work to handle a multipart form.  Is this overhead enough to
imply that only html forms that include the file input element (upload
data) should be multipart forms?

Gary

-----Original Message-----
From: Martin Gainty [mailto:mgainty@hotmail.com]
Sent: Friday, January 09, 2004 10:43 AM
To: Struts Users Mailing List; vanmatre@wyantdata.com
Subject: Re: Seeking multipart-form advise

Drop all the logos
convert html (or any markup language) to text
compress
(total savings can be 95% or the resultant compressed file is 5% of the
file's original size)
then upload
http://www.brownsbox.com/site.php?pn=compress
Does this help?
-Martin

----- Original Message -----
From: "Gary VanMatre" <va...@wyantdata.com>
To: <st...@jakarta.apache.org>
Sent: Friday, January 09, 2004 12:22 PM
Subject: Seeking multipart-form advise


> We are working on an application that has several pages that require
> file upload capabilities.  Currently, our main tiles layout contains
our
> html form tag and we are considering adding the
> enctype="multipart/form-data" attribute to the form tag in our main
> layout but we are uncertain as to the overhead/cost of doing this.
>
> Is there a significant cost associated with making all forms multipart
> in your web application?  Any experiences or insights would be greatly
> appreciated.
>
> Gary
>
>

---------------------------------------------------------------------
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


RE: Seeking multipart-form advise

Posted by Gary VanMatre <va...@wyantdata.com>.
I guess I should have been more specific, I was looking for advice as to
if the "enctype" attribute of the form tag introduces significant
overhead in struts.  I know that the struts request processor has to do
some extra work to handle a multipart form.  Is this overhead enough to
imply that only html forms that include the file input element (upload
data) should be multipart forms?

Gary

-----Original Message-----
From: Martin Gainty [mailto:mgainty@hotmail.com] 
Sent: Friday, January 09, 2004 10:43 AM
To: Struts Users Mailing List; vanmatre@wyantdata.com
Subject: Re: Seeking multipart-form advise

Drop all the logos
convert html (or any markup language) to text
compress
(total savings can be 95% or the resultant compressed file is 5% of the
file's original size)
then upload
http://www.brownsbox.com/site.php?pn=compress
Does this help?
-Martin

----- Original Message -----
From: "Gary VanMatre" <va...@wyantdata.com>
To: <st...@jakarta.apache.org>
Sent: Friday, January 09, 2004 12:22 PM
Subject: Seeking multipart-form advise


> We are working on an application that has several pages that require
> file upload capabilities.  Currently, our main tiles layout contains
our
> html form tag and we are considering adding the
> enctype="multipart/form-data" attribute to the form tag in our main
> layout but we are uncertain as to the overhead/cost of doing this.
>
> Is there a significant cost associated with making all forms multipart
> in your web application?  Any experiences or insights would be greatly
> appreciated.
>
> Gary
>
>

---------------------------------------------------------------------
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


Re: Seeking multipart-form advise

Posted by Martin Gainty <mg...@hotmail.com>.
Drop all the logos
convert html (or any markup language) to text
compress
(total savings can be 95% or the resultant compressed file is 5% of the
file's original size)
then upload
http://www.brownsbox.com/site.php?pn=compress
Does this help?
-Martin

----- Original Message -----
From: "Gary VanMatre" <va...@wyantdata.com>
To: <st...@jakarta.apache.org>
Sent: Friday, January 09, 2004 12:22 PM
Subject: Seeking multipart-form advise


> We are working on an application that has several pages that require
> file upload capabilities.  Currently, our main tiles layout contains our
> html form tag and we are considering adding the
> enctype="multipart/form-data" attribute to the form tag in our main
> layout but we are uncertain as to the overhead/cost of doing this.
>
> Is there a significant cost associated with making all forms multipart
> in your web application?  Any experiences or insights would be greatly
> appreciated.
>
> Gary
>
>

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