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.
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.
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.