您的位置:首页 > 运维架构 > Tomcat

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

2009-08-16 05:36 477 查看
运行应用程序

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

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服务器是如何工作的。这章附带的程序仅仅由三个类组成,并不是全功能的。不过,它提供了一个良好的学习工具。下一章将要讨论动态内容的处理过程。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: