Tomcat 学习(二)--一个简单的Web服务器
2008-05-31 15:44
323 查看
一个Web Server 也叫做 HTTP Server,因为它用HTTP来和客户端(web浏览器)沟通。
基于Java的web server使用两个类: java.net.Socket 和 java.net.ServerSocket。
HTTP
是一个request和response协议。客户端请求一个文件,服务器答复这个请求。HTTP使用可靠的TCP连接。
HTTP Request 包括:
- Method - Uniform Resource Identifier (URI) - Protocol/Version
- Request headers
- Entity body
例如:
POST /examples/default.jsp HTTP/1.1 Accept: text/plain; text/html Accept-Language: en-gb Connection: Keep-Alive Host: localhost User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 98) Content-Length: 33 Content-Type: application/x-www-form-urlencoded Accept-Encoding: gzip, deflate lastName=Franks&firstName=Michael
HTTP1.1支持七种request类型:GET, POST, HEAD, OPTIONS, PUT, DELETE 和 TRACE, 用最多的是GET 和POST。
HTTP Response包括:
- Protocal - Status Code - Description
- Response headers
- Entity body
例如:
HTTP/1.1 200 OK Server: Microsoft-IIS/4.0 Date: Mon, 5 Jan 2004 13:13:33 GMT Content-Type: text/html Last-Modified: Mon, 5 Jan 2004 13:13:12 GMT Content-Length: 112 <html> <head> <title>HTTP Response Example</title> </head> <body> Welcome to Brainy Software </body> </html>
阅读更多
相关文章推荐
- tomcat是怎么工作的学习——一个简单的web服务器
- [Tomcat服务器 --- 一个简单的基于HTTP WEB服务器]
- Tomcat剖析(一):一个简单的Web服务器 ---转载
- Tomcat是怎么炼成的?(2)一个最简单的Web服务器
- Tomcat学习(一)——简单的web服务器
- Tomcat-001-一个简单的web服务器
- 深入剖析tomcat(一)--一个简单的web服务器
- Tomcat剖析(一):一个简单的Web服务器
- 我的Go语言学习之旅八:创建一个简单的WEB服务器
- 深入剖析tomcat之一个简单的web服务器
- 用Tomcat做一个简单的服务器,可以是非Web服务器
- 走进tomcat之一个简单Web服务器
- 《How To Tomcat Works》-第一章:一个简单的Web服务器
- 学习用node.js建立一个简单的web服务器
- how tomcat works 读书笔记(一)----------一个简单的web服务器
- how tomcat works 读书笔记(一)----------一个简单的web服务器
- [How Tomcat Works]第1章 一个简单的Web服务器
- 用java实现的一个简单web服务器程序
- 使用C# socket 简单构架一个web服务器
- Java 实现一个简单的web服务器