You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "CHOY, ALAN" <al...@cgi.com> on 2004/01/22 19:13:16 UTC

Use FileUpload in Struts framework

Reference:
http://www.mail-archive.com/commons-user@jakarta.apache.org/msg02231.html

I've found the reference above and found out the same thing by testing
that FileUpload didn't reallly work well with Struts, because the
HttpRequest input stream had already been exhausted by Struts, and
FileUpload would return a List of zero size after parsing the
HttpRequest.

I'm just wondering if anyone has any get around for this.  I am using
Struts 1.0.2, and I'm wondering if Struts 1.1 will do the trick and make
it work.



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


Re: Use FileUpload in Struts framework

Posted by Martin Cooper <ma...@apache.org>.
On Thu, 22 Jan 2004, CHOY, ALAN wrote:

> Hi Martin,
>
> I've upgraded my application to Struts 1.1, and I still encountered the same
> problem (i.e. not be able to work with FileUpload).  So in this case, should I
> just use org.apache.struts.upload package?

You should probably take this up on the struts-user list, rather than on
this list. However, I'll point out that, next to attempting to do your own
file upload handling, the next most common cause of this problem is the
use of action chaining in Struts apps. Action chaining is bad, and this is
only one of the issues you might see with it.

>
> However, I noticed some of the classes in org.apache.struts.upload package are
> deprecated, and the javadoc suggest to use commons-fileupload instead?  If this
> is the case, would you please let me know how to get around the original
> problem (i.e. InputStream has been consumed)?

That's not quite right - you need to read the Javadoc more carefully. The
old (Struts-only) implementation has been deprecated in favour of a newer
Commons FileUpload BASED implementation. In terms of multipart handler
classes, that means using CommonsMultipartRequestHandler (which uses
Commons FileUpload, and which is now the default multipart handler in
Struts) instead of DiskMultipartRequestHandler (which was the default in
Struts 1.0.2, and is pretty buggy).

--
Martin Cooper


> __________________________________________________________
>
> Martin Cooper wrote:
>
> > On Thu, 22 Jan 2004, CHOY, ALAN wrote:
> >
> > > Reference:
> > > http://www.mail-archive.com/commons-user@jakarta.apache.org/msg02231.html
> > >
> > > I've found the reference above and found out the same thing by testing
> > > that FileUpload didn't reallly work well with Struts, because the
> > > HttpRequest input stream had already been exhausted by Struts, and
> > > FileUpload would return a List of zero size after parsing the
> > > HttpRequest.
> >
> > Struts already handles multipart requests, so you should not be trying to
> > do that also, within a Struts application. That's when you'll find that
> > the input stream has already been consumed (by Struts).
> >
> > >
> > > I'm just wondering if anyone has any get around for this.  I am using
> > > Struts 1.0.2, and I'm wondering if Struts 1.1 will do the trick and make
> > > it work.
> >
> > If you're using Struts 1.0.2, and you need to do file upload, move to
> > Struts 1.1 NOW. Seriously. There were a lot of bugs in the Struts 1.0.2
> > file upload handling, and the entire implementation was replaced in 1.1,
> > using Commons FileUpload as the core.
> >
> > --
> > Martin Cooper
> >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> > >
> > >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>

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


Re: Use FileUpload in Struts framework

Posted by "CHOY, ALAN" <al...@cgi.com>.
Hi Martin,

I've upgraded my application to Struts 1.1, and I still encountered the same
problem (i.e. not be able to work with FileUpload).  So in this case, should I
just use org.apache.struts.upload package?

However, I noticed some of the classes in org.apache.struts.upload package are
deprecated, and the javadoc suggest to use commons-fileupload instead?  If this
is the case, would you please let me know how to get around the original
problem (i.e. InputStream has been consumed)?
__________________________________________________________

Martin Cooper wrote:

> On Thu, 22 Jan 2004, CHOY, ALAN wrote:
>
> > Reference:
> > http://www.mail-archive.com/commons-user@jakarta.apache.org/msg02231.html
> >
> > I've found the reference above and found out the same thing by testing
> > that FileUpload didn't reallly work well with Struts, because the
> > HttpRequest input stream had already been exhausted by Struts, and
> > FileUpload would return a List of zero size after parsing the
> > HttpRequest.
>
> Struts already handles multipart requests, so you should not be trying to
> do that also, within a Struts application. That's when you'll find that
> the input stream has already been consumed (by Struts).
>
> >
> > I'm just wondering if anyone has any get around for this.  I am using
> > Struts 1.0.2, and I'm wondering if Struts 1.1 will do the trick and make
> > it work.
>
> If you're using Struts 1.0.2, and you need to do file upload, move to
> Struts 1.1 NOW. Seriously. There were a lot of bugs in the Struts 1.0.2
> file upload handling, and the entire implementation was replaced in 1.1,
> using Commons FileUpload as the core.
>
> --
> Martin Cooper
>
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >
> >



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


Re: Use FileUpload in Struts framework

Posted by Martin Cooper <ma...@apache.org>.
On Thu, 22 Jan 2004, CHOY, ALAN wrote:

> Reference:
> http://www.mail-archive.com/commons-user@jakarta.apache.org/msg02231.html
>
> I've found the reference above and found out the same thing by testing
> that FileUpload didn't reallly work well with Struts, because the
> HttpRequest input stream had already been exhausted by Struts, and
> FileUpload would return a List of zero size after parsing the
> HttpRequest.

Struts already handles multipart requests, so you should not be trying to
do that also, within a Struts application. That's when you'll find that
the input stream has already been consumed (by Struts).

>
> I'm just wondering if anyone has any get around for this.  I am using
> Struts 1.0.2, and I'm wondering if Struts 1.1 will do the trick and make
> it work.

If you're using Struts 1.0.2, and you need to do file upload, move to
Struts 1.1 NOW. Seriously. There were a lot of bugs in the Struts 1.0.2
file upload handling, and the entire implementation was replaced in 1.1,
using Commons FileUpload as the core.

--
Martin Cooper


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

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