I have a scenario where I want to tell the user that download is completed and prompt a close button. For this I am using a jquery plugin which monitors a cookie continuously to know when this download completes.
My problem is I want to set this cookie (fileDownload = true and path="/"
) as soon as the download gets completes. For this I tried various location for setting this cookie. But every time the cookie get set before the download even begin.
The code for setting cookie.
Cookie fileDwnld = new Cookie("fileDownload", "true");
fileDwnld.setPath("/");
response.addCookie(fileDwnld);
I am setting this on a Servlet which also has the code to fetch the file and stream it through output stream to the browser.
My only problem is the cookie get set before the file get downloaded.
Any suggestion. I am using Tomcat 7. Java 1.6, Servlet. The jquery plugin I am using is fileDownload.js (Which I believe is not a culprit).
Thanks in advance.