This week's giveaway is in the Testing forum. We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line! See this thread for details.
I have to implement a functionality - delete the file on server when user download file is complete. we do not want store that file on server anymore.
I m using struts2 for downloading file on tomcat server. How can i identify file downloading is complete. as of now, i can download file successfully but when the file should be deleted?
write a custom interceptor to delete the file and make sure that this will be executed only after successful completion of downloading file. Ask me if you have any doubts.
ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Mind using AJAX? Here's a comprehensive solution that you can relate your question to. Here's a bit more insight into the same. Or even this could be of some help.
Not into AJAX? The following code snippet in your servlet is supposed to let you know if the download has completed.
Supposedly, the file download will be completed as soon as the while loop is exited.
Hope that helps.
Coderanch, best ever forum on the net. Hands down.
Mohana Rao wrote:write a custom interceptor to delete the file and make sure that this will be executed only after successful completion of downloading file. Ask me if you have any doubts.
actually I am not sure about Interceptor is the good idea. Intercept just intercept the Action execution. It will not have information when the end of stream occurred. Browser transfer files over http So i think there is something different kind of solution.
Interceptors are objects that dynamically intercept Action invocations. They provide the developer with the opportunity to define code that can be executed before and/or after the execution of an action. They also have the ability to prevent an action from executing. Interceptors provide developers a way to encapulate common functionality in a re-usable form that can be applied to one or more Actions. So, write an interceptor which is responsible for deleting the file. It(Interceptors) will not be called until and unless you result execution is successful.
ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Mohana Rao wrote: Interceptors are objects that dynamically intercept Action invocations. They provide the developer with the opportunity to define code that can be executed before and/or after the execution of an action. They also have the ability to prevent an action from executing. Interceptors provide developers a way to encapulate common functionality in a re-usable form that can be applied to one or more Actions. So, write an interceptor which is responsible for deleting the file. It(Interceptors) will not be called until and unless you result execution is successful.
thanks for your help.
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth