History of web development:

  • Early Web applications were mainly used to browse static pages such as news. HTTP servers (such as Apache and Nginx) returned static HTML to the browser, which parsed the HTML and presented the results to the user.
  • Through some interactive operations, to obtain dynamic results, so there is a need for some extension mechanism to enable HTTP server to call the server program, Sun introduced the Servlet technology.
  • A Servlet is a Java applet that runs on the server side, but a Servlet does not have a main method and cannot run on its own, so it must be deployed into a Servlet container that instantiates and invokes the Servlet.
  • Tomcat is a Servlet container. They also function as HTTP servers for ease of use, so Tomcat is an “HTTP server +Servlet container,” or Web container as we call them.

The browser needs to get an HTML text from a remote HTTP server

  • The Socket connection is set up with the server.
  • Generate request data and send it over the Socket.

HTTP request data consists of three parts, namely, request line, request header and request body.