Servlet is a server-side program written in Java language. It can generate dynamic web pages. It mainly runs on the server side and is executed and called by the server. In addition, it also has powerful transaction processing capabilities.
Servlet is a server-side program written in Java language. It can generate dynamic web pages. It mainly runs on the server side and is executed and called by the server. In addition, it also has powerful transaction processing capabilities
Servlet is a technology provided by sun company for developing dynamic web resources. Next, I will introduce this technology in detail in the article, which has certain reference Value, I hope it will be helpful to everyone
[Recommended tutorial: servlet tutorial]
What is servlet
Servlet is a server-side program written in Java language. It can generate dynamic WEB web pages like JSP. Servlet mainly runs on the server side and is called by the server. A class developed according to Servlet standards. According to the request submitted by the user, the servlet program returns the results or related information to the client browser after running on the application server. And it has powerful transaction processing capabilities.
In reality, servlets can respond to any type of request, but in most cases Servlets are only used to extend web servers based on the THHP protocol
Servlet workflow
The servlet is used to receive the request sent by the browser to the server and send the server's response to the request back to the browser. This process
is transmitted through the HTTP protocol.
(1) First, the browser assembles the relevant information into the requested HTTP message according to the specifications of the HTTP message, and sends it to the designated server through the network.
(2) Secondly, after the server receives the HTTP message sent by the browser, it uses web containers such as Tomcat, jetty, and Jboss to extract and parse the HTTP message. If it is found to be a request, The web container will store the parsing result of this message as a request object, which looks like "the request sent by the browser to the server".
(3) Then, after the server-side program processes the request, it places the processing result in the response object, and encapsulates it into an HTTP protocol message according to the specifications of the HTTP protocol and sends it back to the browser.
(4) Finally, after the browser receives the HTTP message containing the response information, it parses the message and displays the processing results on the browser.
Summary: The above is the entire content of this article, I hope it will be helpful to everyone.
The above is the detailed content of What is servlet. For more information, please follow other related articles on the PHP Chinese website!