Download file
I have a small servlet that allows the user to download a file.
My problem is that I don't know how to check whether or not they accepted to download the file or the hit the 'cancel' button.
here is a small chunk of code:
res.setContentType("text/plain");
res.setContentLength(file.length);
res.setHeader("Content-Disposition","attachment;filename=" + ename);
res.getOutputStream().write(file);
//perform another action based on user action
I need to know after "res.getOutputStream().write(file);" whether or not the user accepted the download. Any help is greatly appreciated.
[743 byte] By [
uberallesa] at [2007-11-27 9:03:49]

# 1
I don't think there is anyway to capture that event; the user may not even get an option to Open/Save/Cancel; for example, PDFs always simply open in my browser without any prompt unless I right-click and click on 'Save Target As' ( using IE 6 with the Acrobat Reader Plugin ).
What action do you want to perform anyway?
# 2
Basically once that file is downloaded I have to change its status in the db to 'taken'. After 24 hours it changes back to 'available'. I was thinking of just adding a confirmation where the user just clicks on a button confirming that they received the file and then the status gets changed.
Any way for me to do a page reDirect after the download?
Thanks in advance.