Servlet Life Cycle in Java

Video ready, click here to close ×


Hi there, this is Arvind, welcome to my channel. In this session we are gonna see the life cycle of servlet.

Servlets are singleton, i.e. WebContainer creates only single instance of given servlet.

#init:
invoked only once, on: 1# first request, 2# loaded with startup flag

#service:
for each request

#destroy:
servlet cease to exist on: 1# webapp undeployed, 2# server shutdown

#Inorder to get destroy message, please follow the below steps

If you are using Netbeans, from left panel # Services # Servers # Choose and expand server, either Apache or Glassfish # Web Applications # Choose your application # Right Click # Stop or Undeploy.

OR

Also below main editor panel, Output tab # Server tab, either Apache or Glassfish # Click red square icon to stop server.

source

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *