I have a problem with Struts 2 and its file upload interceptor. It is have validated my content type and my file size, but the upload process dont stop. Example my upload limit is 2Mb and user send a file with 500MB, the interceptor struts 2 log that file is too larger, but continue upload file
I'd like to stop the upload process, in error case, beacuse the struts2 have returned to my page only when the sending file is finished.
Thanks
You can't in Struts - since Struts doesn't get hold of the response object until your servlet container has finished processing it.
However - most containers have a means of controlling upload file sizes and, for tomcat, this is the maxPostSize parameter (default is 2GB) - as far as I can tell tomcat will count the number of incoming bytes and then exit if this value is exceeded. i.e Tomcat will not continue reading past maxPostSize. Other containers will have similair configuration parameters. I've never used it so I can't be of any further help here.
If you have nested containers/serves (for example, tomcat sitting behind Apache Web Server) make sure you configure the right one
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With