What is Java Servlet?- A servlet is a java class / a program that is a server side component and runs in a web container.
- The servlet generates the dynamic content.
- The content is dependent on the client request.
- It is used to extend the capabilities of servers that host applications accessed by means of a request-response programming model.
- They can respond to any type of request which are commonly used to extend the applications hosted by web servers. For such type of applications, Java Servlet technology defines HTTP-specific servlet classes.
- The javax.servlet and javax.servlet.http packages provide interfaces and classes for writing servlets.
- All servlets implement the Servlet interface, which define the different life-cycle methods.
- When implementing a generic service, you can use or extend the GenericServlet class provided with the Java Servlet API.
- The HttpServlet class provides methods, such as doGet and doPost, for handling HTTP-specific services.