What is Servlets and explain the advantages of Servlet life cycle?- Servlets are the programs that run under web server environment.
- A copy of servlet class can handle numerous request threads.
- In servlets, JVM stays running and handles each request using a light weight thread.
- Servlets life cycle involve three important methods are:
1. Init() 2. Service() 3.Destroy()
1. Init() : - Init() method is called when servlet first loaded into the web server memory.
2. Service() : - Once initialized, servlets stays in memory to process requests. - Servlets read the data provided in the request in the service() method.
3. Destroy() : - When server unloads servlets, destroy() method is called to clean up resources the servlet is consuming.
|