Pankaj:
Are you using the alternate constructor for MultipartRequest?:
public MultipartRequest(HttpServletRequest request,
String saveDirectory,
int maxPostSize) throws IOException
The code for this above constructor has the following call:
parser = new MultipartParser(request, maxPostSize);
And in the code for constructor for MultipartParser is the check you are looking
for:
// Check the content length to prevent denial of service attacks
int length = req.getContentLength();
if (length > maxSize) {
throw new IOException("Posted content length of " + length +
" exceeds limit of " + maxSize);
}
So you see Jason has already taken care of this for you!! (:-) .. All you have to
do is catch the IOException and redirect to your error.html.. unless you want to
distinguish between the different kinds of exceptions (file too big and file cant
be parsed??))
Geeta
Pankaj C Rajankar wrote:
> Hello everybody,
>
> I am using the multipart request classes by Jason Hunter for a file upload
> utility.
> I want to avoid the uploads if the file size is large.
>
> I check for
> request.getContentLength() and throw a exception if the files size is big.
>
> In the catch block I have the following:
> {
> ServletInputStream in = request.getInputStream();
> in.skip(lUploadSize);
> in.close();
> response.sendRedirect("/error.htm");
> }
>
> I get an error, connection reset by peer, on execution.
>
> Could anyone plese point out the mistake I am making.
>
> Thanks,
> Pankaj..
>
> This communication is for informational purposes only. It is not intended as
> an offer or solicitation for the purchase or sale of any financial instrument
> or as an official confirmation of any transaction. All market prices, data
> and other information are not warranted as to completeness or accuracy and
> are subject to change without notice. Any comments or statements made herein
> do not necessarily reflect those of J.P. Morgan Chase & Co. Incorporated, its
> subsidiaries and affiliates.
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html