Why should we learn servlets? What are servlets for?

I just finished learning servlet recently, and I understand one thing, what is servlet used for, why should I learn servlet, I think if I understand this when I just started learning servlet, it will be more beneficial to my purpose To learn about servlets; so record the following articles:

What are servlets?

        Speaking of servlets what is it? We have to see what is the essence of servlet? The essence of a servlet is a set of interfaces. What is the interface used for? The role of the interface is to standardize certain things; so the servlet specification is used to standardize certain rules;
        we learned about servlets when we were learning Javaweb, so what role does servlet have for Javaweb? If we want to visit a website, we need to tell the web browser our needs, and then the web browser responds to the corresponding needs through our needs and feeds back to us; so the role of the servlet is derived;

The role of servlet?

        The servlet interface defines a set of specifications for processing network requests . All classes that implement servlets need to implement the five methods to tell the web browser what to do when you initialize?—(init method); you destroy What do you do when you receive a request?—(destory method); What do you do when you receive a request?—(service method); However, in practical applications, we will not directly implement the servlet interface, but will implement its sub-interface Httpservlet  interface ;

        Generally speaking, the servlet is specially used to receive the client's request, through the client's request data, call the underlying service method to process the data and generate the result feedback to us. The process can be roughly as follows:

The browser sends an http request --> tomcat server --> reaches the servlet --> executes doGet(), doPost() methods --> returns data

The client sends a request to the server-the server sends the request information to the servlet-the servlet generates the response content and passes it to the server. - The server returns the response to the client.

Guess you like

Origin blog.csdn.net/m0_64231944/article/details/128836329