What is Servlet and its life cycle

36 0 0
                                    

Servlets: -

Servlets are modules that extend request/response-oriented servers, such as java-enabled web servers.

Life cycle of a servlet: -

A server loads and initializes the servlet by init () method

The servlet handles zero or more client’s requests through service() method

The server removes the servlet through destroy() method.

Servlet mapping: - 

The servlet mapping defines an association between a URL pattern and a servlet. The mapping is used to map requests to Servlets

Servlet chaining: - 

Servlet chaining is a technique in which two or more servlets can cooperate in servicing a single request.

In servlet chaining, one servlet’s output is piped to the next servlet’s input.

This process continues until the last servlet is reached.

Its output is then sent back to the client

Also see the following Java video on overview and working of Servlets.

Visit our site for more such JAVA/Core JAVA/J2EE/JSF/EJB/GWT/Apache CXF interview questions with answer videos.

What is Servlet and its life cycleWhere stories live. Discover now