This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Servlets and the fly likes problem with restricting size of uploading file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "problem with restricting size of uploading file" Watch "problem with restricting size of uploading file" New topic

problem with restricting size of uploading file

Ravi Kumarasinghe

Joined: Apr 08, 2002
Posts: 12
Hi all,
I have a file uploading servlet. In that I need to limit the file size to 1MB. I can get the file size at the beginning using request.getContentLength().
Now I need to send output message to the client using the response.getWriter().println(message);
This command is getting executed, but the servlet is not sending the response until I read the whole file in the request body.
I need to avoid unnecessarily reading a large file. Is there a way to send a message to the client form the servlet initially without reading the whole uploaded file ?
I tried the 'Orielly' package also. THat is also having the same problem.
The 'jspsmart' sample program works but it seems that they are also reading the whole uploaded file before giving the error message.
Even Hotmail uploads the whole file blindly before giving the error message
BUT somehow yahoo mail does it. It give the file too large error very quickly without reading the whole file. SO there has to be a way.
Can anyone PLEASE help me
Thanks a lot
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
Welcome to the JavaRanch! Please adjust your display name to meet
the JavaRanch Naming Policy. You can change it here.
and welcome to the JavaRanch!
I agree. Here's the link:
subject: problem with restricting size of uploading file
It's not a secret anymore!