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.
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".
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.
subject: stop downloading the uploaded file on a event