Skip to main content

Servlet destroy() Method

Learn Servlet destroy() Method (Servlet Lifecycle, JSP Servlets) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

What is destroy() Method? • The destroy() method is a lifecycle method of a servlet. • It is called only once. • Called before the servlet is removed from memory. • Used for cleanup activities. When is destroy() Called? • When server is shutting down • When servlet is reloaded • When application is undeployed Lifecycle Order • init() → called once • service() → called multiple times • destroy() → called once

More lessons in Servlet Lifecycle