0 What Is A Servlet? And Life Cycle Of Servlet

Опубликовано: 17 Март 2025
на канале: Sameer's Code Room
8,472
109

Servelt:
Servlet Is a technology and is used to Create a Web Appliactions
Servlet is java class which extends the functionality of web server by dynamically generating web pages.
Servlet technology is used to create Dynamic web application.

init():
The server basically invokes the init() method of servlet.
This method is called only when the servlet is loaded in the memory for the first time.
The class loader is responsible to load the servlet class


Service():
The service() method is the main method to perform the actual task.
The servlet container (i.e. web server) calls the service() method to handle requests coming from the client( browsers) and to write the response back to the client.
Each time the server receives a request for a servlet, the server creates a new thread and calls service.


Destory():
Finally server unloads the servlet from the memory using the destroy() method.
The destroy() method is called only once at the end of the life cycle of a servlet.