aspose file tools*
The moose likes Java in General and the fly likes Delete folder on window close Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Delete folder on window close" Watch "Delete folder on window close" New topic
Author

Delete folder on window close

nancy andrew
Ranch Hand

Joined: Jan 19, 2010
Posts: 30
Hi All,

I want to delete a folder and its contents when I close my application browser. Please let me know how to do it using java.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

What is application browser? You mean like Firefox, Chrome?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
nancy andrew
Ranch Hand

Joined: Jan 19, 2010
Posts: 30
Ya any browser explorer, firefox, chrome.. When I click on the X button of the browser (top right side), then one of the folder which I created on my desktop should get deleted
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

I doubt if this is possible.
There may be some solution with Javascript or GreaseMonkey, but I doubt if it will work for all scenarios.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61762
    
  67

What are you really trying to accomplish? Because what you are asking is not possible. Not only is there no way to detect when a browser is closed from a page loaded into the browser, without a signed applet, page code has no way to affect or even see the client file system.

Or are you asking about a desktop program monitoring browser instances? It'd help if you'd spend a bit more time explaining your scenario and requirements.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19783
    
  20

Something tells me this is a web application that creates a folder on the server for a client. That folder is only relevant while the client is still active on the web application.

As said before there is no way to find out when the browser is closed. But there's something close. HttpSession has a matching listener, HttpSessionListener. You configure the usage of such a listener in the web.xml file. You then use the sessionDestroyed method to be notified when the session is removed. This may be hours after the browser is closed, but it's as close as you're going to get.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Delete folder on window close