aspose file tools*
The moose likes Applets and the fly likes Destroy method of Applet... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Destroy method of Applet..." Watch "Destroy method of Applet..." New topic
Author

Destroy method of Applet...

Ananth Chellathurai
Ranch Hand

Joined: Nov 21, 2007
Posts: 349

Is the destroy method called only at the time of browser close? I am using a buffered reader for my applet. I need to close the buffer at the end, when I close the buffer in the destroy method it gets closed after the applet is loaded completely. For further usages I am not able to access the buffered reader. How to close the buffer when the browser is closed or when the user navigates to some other page.

Ananth


Ananth Chellathurai [Walk on software]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42286
    
  64
What kind of Reader is this, and why does it need to be kept open? The most natural thing to do would be to close the Reader when you're done with it.

To investigate the applet lifecycle you should write a little applet that prints messages to System.out whenever one of its lifecycle methods is called (init, start, stop, destroy). Then you'll get a feeling what code might go into which method. Also, not all browsers/JVMs are fully consistent as to when they call these methods.


Ping & DNS - my free Android networking tools app
Ananth Chellathurai
Ranch Hand

Joined: Nov 21, 2007
Posts: 349

Thanks Ulf.

I found that buffered reader cannot be re used. I gave a System.out in destroy method, and I found it is getting printed after every time the page load is complete. Now I am closing the buffered reader after use, and going to a servlet again to get the buffered reader when needed.

Thanks buddy
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Destroy method of Applet...