Advertisement



< Prev
Next >



Lifecycle of a Servlet





There are four stages in the lifecycle of a Servlet -





At the end, the Servlet Container may call the destroy() method on the Servlet class when an exception is thrown during the execution of service() method, which says the Servlet is permanently unavailable.


What happens when a Servlet decides to destroy the instance of Servlet

When a Servlet Container decides to destroy an instance of Servlet, it stops taking any new user request for this particular Servlet. Meanwhile, the Servlet Container waits until all the threads currently executing the service() method finish their job and eventually the Servlet Container calls the destroy() method. Calling destroy method makes sure there are no references to the object of this Servlet and thus making it eligible for garbage collection.



Please share this article -




< Prev
Next >
< Introduction to Servlets
Lifecycle methods of Servlet >



Advertisement

Please Subscribe

Please subscribe to our social media channels for daily updates.


Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page




Advertisement



Notifications



Please check our latest addition

C#, PYTHON and DJANGO


Advertisement