There are three classes in total for this section: Request\response\httpserver---User.dir The purpose of this section is to implement simple Web server access to static files. Need to understand the request header, the format of the request body, otherwise there is no way to parse. 1, Request: The Main method is the parse, the main logic of the method is to parse the socket inputstream, read the input stream, parse out the request to access the address URI, such as:/index.jsp parsing the URI, is the standard format for HTTP request parsing : get/articles/news/today.asp http/1.1 2, Response: This class constructor requires the request object for the purpose of obtaining the file path to be accessed through Request.geturi (). The stitching path finds the actual file and then writes the file as a stream through the outputstream of the socket. 3, Httpserver: Create a ServerSocket, responsible for listening to the socket request, get the socket object, and then generate the request and response object, to the socket side to return data. Start by Httpserver#main method, Access http://localhost:8080/index.jsp;
Siege Lion on the road (restaurant) how Tomcat works (a) simple Web server