You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Marc <ru...@gmx.de> on 2003/06/30 09:38:33 UTC

File Upload size restriction ??

Hallo,

I have short question according file-upload with struts:

What happens, when the configured maximal buffersize (element 
<controller maxFileSize="2500K" /> in struts-config) is exceeded by an 
user-upload ?

The data seems to be ignored, but how can I deteced such a case so that 
I can send an error-message back to the user ?

I never got this MaxLengthExceededException mentioned in the API.

Any hints ?

Thank you

Markus



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


Re: File Upload size restriction ??--another question--urgent

Posted by Marc <ru...@gmx.de>.
Prashanth.S wrote:
> Hi all,
> Is there any limit on the size of the file to be uploaded when i use struts...
> Iam using FormFile interface for struts upload...
> Is  there  any limit on the size of the file that is being uploaded...Iam getting error when i am uploading large files even though iam not using any validations...
> Waiting for reply
> Thanking you
> Prashanth

Don't know about the TomCat capacity with file-uploads, but you must 
define the upload-buffer size within the <controler> Tag in your 
struts-config XML.

The Struts docu says:

'maxFileSize - The maximum size (in bytes) of a file to be accepted as a 
file upload. Can be expressed as a number followed by a "K", "M", or 
"G", which are interpreted to mean kilobytes, megabytes, or gigabytes, 
respectively. [250M] (optional)'

So if not set, the upload should be limited to 250 MBytes.

Regards

Markus



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


Re: File Upload size restriction ??

Posted by Nicolas De Loof <ni...@cgey.com>.
I Tried Struts upload example App and it works fine. So browser or tomcat conf are not responsible.

Do you have any idea what I can look at to discover what works wrong on my app ?

Nico.




> Nicolas De Loof wrote:
> > In fact I've got this strange behaviour :
> > 
> > - Form-bean is validated a first time. MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED is setted and an
> > ActionError is returned by validate().
> > 
> > - browser go on uploading for a long time ... (5 minutes for 10Mo upload on localhost)
> > 
> > - validate is called A SECOND TIME.
> > MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED is setted and an ActionError is returned by validate().
> > 
> > - browser show errors.
> > 
> > 
> > My code looks like Struts upload example. I certainly not understood something !
> > 
> > Nico.
> 
> Tried a 135 MBytes upload on localhost. Took 10 sec to complete and the 
> returned JSP-paged showed the correct error in the browser.
> 
> Maybe you should check first, why the uploads takes so long on your machine.
> 
> Regards
> 
> Markus
> 
> 
> 
> ---------------------------------------------------------------------
> 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: File Upload size restriction ??

Posted by Marc <ru...@gmx.de>.
Nicolas De Loof wrote:
> That's what I was trying to do and discovered that upload behaviour changes when going over Struts configured file-size
> limit (4Mo in my case)
> 
> With a 3Mo file it works fine.
> With a 4,4Mo file I get errors on logs but upload goes on in the browser, and after a long while (3 minutes) I get
> others validate() logs (related with no-file errors) and the errors are displayed on browser.
> 
> I don't understand why I get TWO TIMES validate() logs !!
> 
> If i set the size-limit to "6M", 4,4Mo upload works well in less than a seconds, but a 10Mo upload takes more than 5
> minutes. I get file-size error logs in the first request seconds, browser stays for a (long) while and I get second
> validation error logs.
> 
> Using IP or machine name doesn't change anything.
> 
> Nico.

Had some mysterious browser-waits too. That had nothing to do with 
file-uploads in my case, but with some mapping-configuration in the 
struts-config.xml.

I finally got a work around when forwarding from an Action-Servlet 
direct to a jsp-page and not through any ActionMapping.

Never figured out the real problem after I find the workaround.

Did you try the struts-example with an upload-limit ?

If this works without problem too, maybe you should play around with 
some different forward mappings...

regards

Markus



Maybe you



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


Re: File Upload size restriction ??

Posted by Nicolas De Loof <ni...@cgey.com>.
That's what I was trying to do and discovered that upload behaviour changes when going over Struts configured file-size
limit (4Mo in my case)

With a 3Mo file it works fine.
With a 4,4Mo file I get errors on logs but upload goes on in the browser, and after a long while (3 minutes) I get
others validate() logs (related with no-file errors) and the errors are displayed on browser.

I don't understand why I get TWO TIMES validate() logs !!

If i set the size-limit to "6M", 4,4Mo upload works well in less than a seconds, but a 10Mo upload takes more than 5
minutes. I get file-size error logs in the first request seconds, browser stays for a (long) while and I get second
validation error logs.

Using IP or machine name doesn't change anything.

Nico.


> Tried a 135 MBytes upload on localhost. Took 10 sec to complete and the
> returned JSP-paged showed the correct error in the browser.
>
> Maybe you should check first, why the uploads takes so long on your machine.
>
> Regards
>
> Markus
>
>
>
> ---------------------------------------------------------------------
> 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: File Upload size restriction ??

Posted by Marc <ru...@gmx.de>.
Nicolas De Loof wrote:
> In fact I've got this strange behaviour :
> 
> - Form-bean is validated a first time. MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED is setted and an
> ActionError is returned by validate().
> 
> - browser go on uploading for a long time ... (5 minutes for 10Mo upload on localhost)
> 
> - validate is called A SECOND TIME.
> MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED is setted and an ActionError is returned by validate().
> 
> - browser show errors.
> 
> 
> My code looks like Struts upload example. I certainly not understood something !
> 
> Nico.

Tried a 135 MBytes upload on localhost. Took 10 sec to complete and the 
returned JSP-paged showed the correct error in the browser.

Maybe you should check first, why the uploads takes so long on your machine.

Regards

Markus



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


Re: File Upload size restriction ??

Posted by Vic Cekvenich <vi...@baseBeans.com>.
Try this API.
http://www.servlets.com/cos/index.html
.V

Nicolas De Loof wrote:

>In fact I've got this strange behaviour :
>
>- Form-bean is validated a first time. MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED is setted and an
>ActionError is returned by validate().
>
>- browser go on uploading for a long time ... (5 minutes for 10Mo upload on localhost)
>
>- validate is called A SECOND TIME.
>MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED is setted and an ActionError is returned by validate().
>
>- browser show errors.
>
>
>My code looks like Struts upload example. I certainly not understood something !
>
>Nico.
>
>
>
>  
>
>>I'm using fileupload too and have difficulties to send errors about file size.
>>
>>Are you able to send an error message with this code ?
>>
>>In my application validate method returns errors (I can see it in logs) when file is too large, but browser does'nt
>>display error JSP (waintg ...). I thing it is waiting for the file to be uploaded or something like this.
>>
>>I'm using tomcat 4.1.24 an IE 6 on Windows 2000.
>>
>>Nico.
>>
>>
>>    
>>
>>>Uups,
>>>
>>>found the answer in one of the strus-examples.
>>>
>>>Here it is for those who are interested.
>>>
>>>Regards
>>>
>>>Markus
>>>
>>>
>>>
>>>
>>>  /**
>>>      * Check to make sure the client hasn't exceeded the maximum
>>>allowed upload size inside of this
>>>      * validate method.
>>>      */
>>>     public ActionErrors validate(ActionMapping mapping,
>>>HttpServletRequest request)
>>>     {
>>>         ActionErrors errors = null;
>>>         //has the maximum length been exceeded?
>>>         Boolean maxLengthExceeded = (Boolean)
>>>
>>>request.getAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED);
>>>         if ((maxLengthExceeded != null) &&
>>>(maxLengthExceeded.booleanValue()))
>>>         {
>>>             errors = new ActionErrors();
>>>             errors.add(ERROR_PROPERTY_MAX_LENGTH_EXCEEDED, new
>>>ActionError("maxLengthExceeded"));
>>>         }
>>>         return errors;
>>>
>>>     }
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>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
>>    
>>

-- 
Vic Cekvenich,
Struts Instructor,
1-800-917-JAVA

Advanced <a href ="baseBeans.com">Struts Training</a> and project recovery in North East.
Open Source <a href ="baseBeans.com">Content Management</a>  basicPortal sofware
Best practice<a href ="baseBeans.com">Struts Support</a> v.1.1 helper ScafflodingXPress




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


Re: File Upload size restriction ??

Posted by Gemes Tibor <ti...@i-trade.hu>.
Nicolas De Loof írta:

>- browser go on uploading for a long time ... (5 minutes for 10Mo upload on localhost)
>  
>
Thou this is not your main problem, I'd like to add a bit:
I experienced similar behaviour w/ IE and found that changing the URL 
from http://localhost:8080/myontext to
http://my.real.ip.address:8080/mycontext solved the slow upload problem.

Tib


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


File Upload size restriction ??--another question--urgent

Posted by "Prashanth.S" <su...@yahoo.com>.
Hi all,
Is there any limit on the size of the file to be uploaded when i use struts...
Iam using FormFile interface for struts upload...
Is  there  any limit on the size of the file that is being uploaded...Iam getting error when i am uploading large files even though iam not using any validations...
Waiting for reply
Thanking you
Prashanth

Nicolas De Loof <ni...@cgey.com> wrote:
In fact I've got this strange behaviour :

- Form-bean is validated a first time. MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED is setted and an
ActionError is returned by validate().

- browser go on uploading for a long time ... (5 minutes for 10Mo upload on localhost)

- validate is called A SECOND TIME.
MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED is setted and an ActionError is returned by validate().

- browser show errors.


My code looks like Struts upload example. I certainly not understood something !

Nico.



> I'm using fileupload too and have difficulties to send errors about file size.
>
> Are you able to send an error message with this code ?
>
> In my application validate method returns errors (I can see it in logs) when file is too large, but browser does'nt
> display error JSP (waintg ...). I thing it is waiting for the file to be uploaded or something like this.
>
> I'm using tomcat 4.1.24 an IE 6 on Windows 2000.
>
> Nico.
>
>
> > Uups,
> >
> > found the answer in one of the strus-examples.
> >
> > Here it is for those who are interested.
> >
> > Regards
> >
> > Markus
> >
> >
> >
> >
> > /**
> > * Check to make sure the client hasn't exceeded the maximum
> > allowed upload size inside of this
> > * validate method.
> > */
> > public ActionErrors validate(ActionMapping mapping,
> > HttpServletRequest request)
> > {
> > ActionErrors errors = null;
> > //has the maximum length been exceeded?
> > Boolean maxLengthExceeded = (Boolean)
> >
> > request.getAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED);
> > if ((maxLengthExceeded != null) &&
> > (maxLengthExceeded.booleanValue()))
> > {
> > errors = new ActionErrors();
> > errors.add(ERROR_PROPERTY_MAX_LENGTH_EXCEEDED, new
> > ActionError("maxLengthExceeded"));
> > }
> > return errors;
> >
> > }
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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


---------------------------------
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

Re: File Upload size restriction ??

Posted by Nicolas De Loof <ni...@cgey.com>.
In fact I've got this strange behaviour :

- Form-bean is validated a first time. MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED is setted and an
ActionError is returned by validate().

- browser go on uploading for a long time ... (5 minutes for 10Mo upload on localhost)

- validate is called A SECOND TIME.
MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED is setted and an ActionError is returned by validate().

- browser show errors.


My code looks like Struts upload example. I certainly not understood something !

Nico.



> I'm using fileupload too and have difficulties to send errors about file size.
>
> Are you able to send an error message with this code ?
>
> In my application validate method returns errors (I can see it in logs) when file is too large, but browser does'nt
> display error JSP (waintg ...). I thing it is waiting for the file to be uploaded or something like this.
>
> I'm using tomcat 4.1.24 an IE 6 on Windows 2000.
>
> Nico.
>
>
> > Uups,
> >
> > found the answer in one of the strus-examples.
> >
> > Here it is for those who are interested.
> >
> > Regards
> >
> > Markus
> >
> >
> >
> >
> >   /**
> >       * Check to make sure the client hasn't exceeded the maximum
> > allowed upload size inside of this
> >       * validate method.
> >       */
> >      public ActionErrors validate(ActionMapping mapping,
> > HttpServletRequest request)
> >      {
> >          ActionErrors errors = null;
> >          //has the maximum length been exceeded?
> >          Boolean maxLengthExceeded = (Boolean)
> >
> > request.getAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED);
> >          if ((maxLengthExceeded != null) &&
> > (maxLengthExceeded.booleanValue()))
> >          {
> >              errors = new ActionErrors();
> >              errors.add(ERROR_PROPERTY_MAX_LENGTH_EXCEEDED, new
> > ActionError("maxLengthExceeded"));
> >          }
> >          return errors;
> >
> >      }
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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: File Upload size restriction ??

Posted by Nicolas De Loof <ni...@cgey.com>.
I'm using fileupload too and have difficulties to send errors about file size.

Are you able to send an error message with this code ?

In my application validate method returns errors (I can see it in logs) when file is too large, but browser does'nt
display error JSP (waintg ...). I thing it is waiting for the file to be uploaded or something like this.

I'm using tomcat 4.1.24 an IE 6 on Windows 2000.

Nico.


> Uups,
>
> found the answer in one of the strus-examples.
>
> Here it is for those who are interested.
>
> Regards
>
> Markus
>
>
>
>
>   /**
>       * Check to make sure the client hasn't exceeded the maximum
> allowed upload size inside of this
>       * validate method.
>       */
>      public ActionErrors validate(ActionMapping mapping,
> HttpServletRequest request)
>      {
>          ActionErrors errors = null;
>          //has the maximum length been exceeded?
>          Boolean maxLengthExceeded = (Boolean)
>
> request.getAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED);
>          if ((maxLengthExceeded != null) &&
> (maxLengthExceeded.booleanValue()))
>          {
>              errors = new ActionErrors();
>              errors.add(ERROR_PROPERTY_MAX_LENGTH_EXCEEDED, new
> ActionError("maxLengthExceeded"));
>          }
>          return errors;
>
>      }
>
>
>
> ---------------------------------------------------------------------
> 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: File Upload size restriction ??

Posted by Marc <ru...@gmx.de>.
Uups,

found the answer in one of the strus-examples.

Here it is for those who are interested.

Regards

Markus




  /**
      * Check to make sure the client hasn't exceeded the maximum 
allowed upload size inside of this
      * validate method.
      */
     public ActionErrors validate(ActionMapping mapping, 
HttpServletRequest request)
     {
         ActionErrors errors = null;
         //has the maximum length been exceeded?
         Boolean maxLengthExceeded = (Boolean)
 
request.getAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED);
         if ((maxLengthExceeded != null) && 
(maxLengthExceeded.booleanValue()))
         {
             errors = new ActionErrors();
             errors.add(ERROR_PROPERTY_MAX_LENGTH_EXCEEDED, new 
ActionError("maxLengthExceeded"));
         }
         return errors;

     }



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