java - How to gracefully delete a file from disk in a web application? -


in our web application based on logic generate file on disk. user's browser can request file. done using ajax. want delete file when there no need it. have done far delete in following situations:

  1. successful completion of logic when file sent user
  2. if there failures before delivery (in case of exceptions i'm deleting file. i've overridden finalize method in case of garbage collection going deleted well).
  3. if user's session terminates. using listener listens httpsessiondestroyedevent. cover scenario in user request file before delivery close browser.

some info application: application based on spring , using singleton-scoped bean injected proxy (aop scoped-proxy) handle file locations in session.

now, here question: if user opens 2 tabs in browser , in 1 of tabs request file (assume long running process) , in second tab, log out of system. in case file generated , there no means deleted system automatically. how can cover scenario?


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -