Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Shared temporary File on server - deletion

 
sonali ag
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I want to delete a file after client closes browser or container/server get shutdown.

This file get created temporarily on server by servicing servlet and is shared among various listeners and servlet .
so i want to clean it up after responding to client.

Can anyone please suggest me the solution?

Also is it necessary to have this file within webapp context ?
or can it be outside my webapp folder? so that it can get deleted .

Thanks in advance.
 
Hasnain Javed Khan
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sonali ag wrote:
I want to delete a file after client closes browser or container/server get shutdown.


For container/server shutdown, you need to implement ServletContextListener Interface and write your cleanup logic in contextDestroyed() method.

As for the first part, there is no way to know if the client has closed the browser since there is no termination signal in HTTP protocol (guys correct me if I'm wrong). Sorry I have no ideas how to handle this case.

sonali ag wrote:
Also is it necessary to have this file within webapp context ?
or can it be outside my webapp folder? so that it can get deleted .


It can be inside or outside the webapp/context_root folder (not in webapp folder.Guys correct me if I'm wrong).

Hope that helped.
Kind Regards.
Hasnain.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic