what is a Servlet?

Servlet is a technology to create web application.

  • This is an API that provide many class and interface which is use to make web application.
  • It is deploy on server to create dynamic website.
  • When we send the first request then servlet container get request and execute my business logic.
  • Servlets are the Java programs that run on the Java-enabled web server or application server. 

There are two type of servlets in java.

generic servlets :- this servlets are protocol-independent and can handle any type of request.

  • Every method of generic servlet inheriting to http servlet. Inside this is an abstract method.
  • It is implementing serializable and servlet config interface.
  • It is in a javax.servlet package.
  • Generic servlet is a class.

HTTP servlets :- this servlets are specific to the HTTP protocol and are used to handle HTTP requests and responses.

what is a Servlet