Remove PDF file from the server after redirection

If you are a Power Builder developer and have any questions about using our products from Power Builder here is the place to post them.
Post Reply
blevy9
Posts: 3
Joined: Mon Feb 02 2004
Location: West Palm Beach

Remove PDF file from the server after redirection

Post by blevy9 »

I am using EAServer with EAF framework and JSP client.
After PDF file was created on the server using Amyuni PDF converter, I use redirection in my JSP code to redirect PDF file to the Client browser:
response.sendRedirect(ls_filename).
I tried to delete the file using File Object:
String s = "myfile.pdf";
File f = new File(s);
f.delete();
The problem is, that I can not delete redirected PDF file, because of browser is using it. As my program retrieve hundreds of reports from database, if PDF files will not be removed, they will occupy all memory on the server.
How to resolve this problem with cleanup server from generated PDF files?
Any help appreciate.
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

I didn't really get your question but why you don't try to delete the pdf not after redirecting it but while redirecting the second file, so you are sure that the browser is not using it anymore.

Hope this helps !
blevy9
Posts: 3
Joined: Mon Feb 02 2004
Location: West Palm Beach

Cleanup the server from PDF files

Post by blevy9 »

WebPage get file name as parameter when redirect this file to the browser. After redirection user just close the browser and name of file lost. There are hundred of clients and hundreds of different files, and program does not know what previous file was to delete when it get another file from another user.
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Post by Jose »

Hello,

When a client system views a PDF document which was redirect to it from a server, the client system is actually view a copy of the PDF document that has been downloaded on their system. In the situation you can delete the source PDF document on the server.

The situation you are describing can occur if the PDF document redirected to the client is a medium to large PDF which had web optimization enabled when generated. In this scenario the PDF document does not get completely downloaded on the client system and therefore can be deleted when be previewed. As mentioned above this issue can be resolved by disabling web optimization when generating the PDF document.

Hope this helps?
Post Reply