I am using sendRedirect JSP method to send pdf file to the browser, and then try to find a way to delete pdf file from the server. I understand, it does not work because of Client Browser is using the file after redirection.
But I need to find out how to delete this file from the server after redirection, as database includes hundreds of files, and if files will not be removed, they will occupy all memory on the server.
I want to try to use onUnload JavaScript event, onUnload handler executed just before the page is unloaded, which occurs when the browser is about to move on to a new page.
But, as the first, I don't know if I am able from JavaScript event handler call JSP script to delete the file;
the second, when onUnload handler is executed, browser could still using redirected file, and the object could not be garbage collected.
But I need to find out how to delete this file from the server after redirection, as database includes hundreds of files, and if files will not be removed, they will occupy all memory on the server.
I want to try to use onUnload JavaScript event, onUnload handler executed just before the page is unloaded, which occurs when the browser is about to move on to a new page.
But, as the first, I don't know if I am able from JavaScript event handler call JSP script to delete the file;
the second, when onUnload handler is executed, browser could still using redirected file, and the object could not be garbage collected.