Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling JSP script from JavaScript handler

Status
Not open for further replies.

blevy9

Programmer
Apr 22, 2003
16
US
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.
 
A more robust solution might be to have a process running on your JSP server that performs a check every XX hours. If the creation date of the PDF is more than, say, 1 hour old... then you can delete it.

Jeff
 
alternatively, just delete files older than X hours or days whenever a pdf is requested.


=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top