Tomcat源码学习(8)How Tomcat works(转)

运行应用程序

    为了运行应用程序,可以在工作目录下敲入下面的命令:

java ex01.pyrmont.HttpServer

    为了测试应用程序,可以打开你的浏览器并在地址栏或网址框中敲入下面的命令:

http://localhost:8080/index.html

    正如Figure 1.1所示,你将会在你的浏览器里边看到index.html页面。

Figure 1.1: web服务器的输出
   
在控制台中,你可以看到类似于下面的HTTP请求:

GET /index.html HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/vnd.ms-excel, application/msword, application/vnd.ms-
powerpoint, application/x-shockwave-flash, application/pdf, */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR
1.1.4322)
Host: localhost:8080
Connection: Keep-Alive

GET /images/logo.gif HTTP/1.1
Accept: */*
Referer: http://localhost:8080/index.html
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR
1.1.4322)
Host: localhost:8080
Connection: Keep-Alive

总结

    在这章中你已经看到一个简单的web服务器是如何工作的。这章附带的程序仅仅由三个类组成,并不是全功能的。不过,它提供了一个良好的学习工具。下一章将要讨论动态内容的处理过程。
原文地址:https://www.cnblogs.com/macula7/p/1960790.html