What is Servlet ?

lalita sahu
NiXiS Institute
Published in
2 min readFeb 21, 2020

Servlet is a technology which is used to create a web page. Servlet is that java program that can perform dynamic web page. The servlet is providing many interface. It is class extends the capabilities of the server and responds to the incoming requests. It can respond tho any request.

Servlet Life Cycle

init() →The Servlet is the entries process.The servlet main method of the Servlet Life Cycle is that the servlet initialized method by the init() the init method is only one time call.

service() → After the initialized client request to servlet of many time is calls service() method, in the service client calls more then one time, and in the service () method more then useful doGet(), doPost(), doDelete(), doPut(),doTrace() etc.

destroy() → The last and impotent is the destruction by the destroy () method,and the same is init method the destroy method is calls only one time.The destroy method is the closed of the application.

There are two types of Servlet Interface

HTTPSERVLETREQUEST INTERFACE

  • getCookies → Cookies can be used to uniquely identify clients to servlet.
  • getQueryString → It is return query string present in the request URL if any.
  • getParameter → Return the value associated with a parameter sent to the servlet as a part of GET or POST request.

HTTPSERVLETRESPONSE INTERFACE

  • addCookies → It is used for specific cookies to header of response.
  • sendError → It send the error response to client using specific status code.
  • getWriter → This is Character-based output stream that enables text data to be sent to the client.

Thanks for the reading …)

--

--