What will happen if I call destroy() method as a last statement of doGet() method. Will it destroy the servlet?? Also when a servlet is being destroyed is the destroy() method first called or is finalize() called?? If anyone knows the answers for the above please let me know.
posted 14 years ago
Hi, when you explicitly call the destroy method, the container executes it and makes the servlet instance to be Garbage collected. regarding the finalize method, it is called when the servlet is about to be garbage collection. Agian the GC is not sure to be called everytime.When the resources are low GC thread will be called by the JVM. So the Destroy method doesn't have any realtion with the Finalize method. Usually Destroy methos is used to release some resources like, Database connections, network connections, files and so on. Cheers.
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads