my dog learned polymorphism
The moose likes Servlets and the fly likes stop downloading the uploaded file on a event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "stop downloading the uploaded file on a event" Watch "stop downloading the uploaded file on a event" New topic

stop downloading the uploaded file on a event

sai prasad tangirala

Joined: Dec 05, 2007
Posts: 4
We are uploading a file from JSP and there would be a "cancel" button. On click on "cancel" button we need to stop the process of reading the uploaded file i.e we should stop the process of reading the stream and writing the file on the disk. We are using apache commons fileupload for this. Some one kindly helps us on this.

Kumar Raja
Ranch Hand

Joined: Mar 18, 2010
Posts: 547

In my personal opinion, I do not think, if it would be possible to stop that is under transmission to the server. Once you click upload, the process begins and clicking "cancel" at a later point, would be a different HTTP request and since HTTP is stateless, it would not know anything what happened earlier or what to stop. So I think it is not possible implicitly. But I would like to see, what experts have to say on this. Though I never tried before, your question made me to think, on those situations where I click "stop" on browser in the middle of some page loading. What kind of requests go to server and how does it handle "Stop".


Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

I think Kumar is right about that. Once the upload has started, there isn't any place to click "Cancel". Of course it's always possible for the user to abort the upload by some other brute force method, like for example closing the browser window or maybe clicking the Back button. However I too don't know what happens at that point. Perhaps you could do some experiments and see for yourself.

Or if you absolutely have to have a Cancel button, perhaps a file-upload applet would be a solution.
I agree. Here's the link:
subject: stop downloading the uploaded file on a event
It's not a secret anymore!