This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Destroy method of Applet...

 
Ananth Chellathurai
Ranch Hand
Posts: 349
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ananth Chellathurai
Ranch Hand
Posts: 349
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic