Hi, greetings
I am developing a file upload servlet,
After parsing the files and doing all the processing,
I am giving back the links to the user to download the modified files.
I want to delete all the files that i have stored after the user has downloaded them, I have written a deleteFiles() function for that, but I dont know how to detect that the user has downloaded files , I want to know how to delete these files.
I tried finalize() method in servlet, but didnt work,
So please help ASAP
CODE
public void deleteFiles()
{
File files[] = baseurl.listFiles();
for(File x:files)
x.deleteOnExit();
File parent = new File(baseurl.getParent());
baseurl.deleteOnExit();
files = parent.listFiles();
for(File x:files)
x.deleteOnExit();
parent.deleteOnExit();
}
and this is my doPost
CODE
public void doPost(HttpServletRequest request, HttpServletResponse response)
{
try
{
checkRequestAndInit(request, response);
parseFormFields(request, response);
if(eord.equals("e"))
doEncrypt();
if(eord.equals("d"))
doDecrypt();
deleteFiles();
}
catch(Exception s) { pr.write("There was an error in servlet"); }
finally { pr.close(); }
}