
Servlet (Server Applet) is the abbreviation of Java Servlet, called a small service program or service connector, a server written in Java It is a terminal program that is independent of platform and protocol. Its main function is to browse and generate data interactively and generate dynamic Web content.
In the narrow sense, Servlet refers to an interface implemented by the Java language. In the broad sense, Servlet refers to any class that implements this Servlet interface. Generally, people understand Servlet as the latter. Servlets run in Java-enabled application servers. In principle, Servlets can respond to any type of request, but in most cases Servlets are only used to extend Web servers based on the HTTP protocol.
Let’s take a look at the servlet interface and its abstract class:
public interface Servlet {
public void init(ServletConfig config) throws ServletException;
public ServletConfig getServletConfig();
public void service(ServletRequest req, ServletResponse res )throws ServletException, IOException;
public String getServletInfo();
public void destroy();
}
public abstract class GenericServlet implements Servlet, ServletConfig,java.io.Serializable {}
public abstract class HttpServlet extends GenericServlet {}Servlet interface - a general Servlet interface that defines the most basic functions of a Servlet
|
|- -GenericServlet abstract class-implements the service interface and implements most of its methods, but the service method is not implemented and requires developers to implement it themselves.
|
|--HttpServlet abstract class-inherits GenericServlet, implements the service interface, rewrites the service method, and determines the request method in the service method, and performs different processing according to different request methods XXXX. Such a class without abstract methods is for others to inherit and use
|
|--XXServlet class. Therefore, during development, we only need to write an XXServlet class, directly inherit HttpServlet, and rewrite the doGet and doPost method
to handle GET requests and POST requests

In general, the interfaces and classes related to servlets are as follows:
Interface: Servlet, ServletConfig, ServletRequest, ServletResponse, HttpServletRequest, HttpServletResponse, ServletContext
##Class: HttpServlet (abstract class), GenericServlet (abstract class)
The above is the detailed content of What classes does servlet inherit?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft





