What is Servlets and explain the advantages of Servlet life cycle?

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.
Different Authentication options available in Servlets
Servlets Authentication options - There are four ways of Authentication options available in servlets...
GenericServlet and HTTPServlet
GenericServlet and HTTPServlet - The Constructor HttpServlet() does nothing because this is an abstract class...
Is possible to have a constructor for a servlet?
Yes, it is possible to have a constructor for a servlet. However, it is not practiced usually. The operations with the constructor...
Post your comment