• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can i use finalize method instead of destroy in servlets

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everybody,

Can any please answer me for the fallowing questions.

1.can i use finalize method insted of destroy method?
2.In which instances the destroy method ll be called?

Thnx in advance.....
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing prevents you from writing a finalize() in a servlet class.
The preferred approach to cleaning up when a servlet goes out of service is the destroy method - see the servlet API.
Anybody seriously interested in servlets should have a copy of the API. You can download it for free from this Sun site.
The idea is that the servlet container will call your servlet's destroy method when the servlet instance is about to be removed - possibly as part of orderly shutdown of the server, possibly for some other reason. Since you are NOT guaranteed that GC will run during server shutdown, finalize is a bad choice.
Bill
 
I am a man of mystery. Mostly because of this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic