web servlet
Servlet:Web简介 (Servlet: Introduction to Web)
Web consists of billions of clients and server connected through wires and wireless networks. The web clients make requests to web server. The web server receives the request, finds the resources and return the response to the client. When a server answers a request, it usually sends some type of content to the client. The client uses web browser to send request to the server. The server often sends response to the browser with a set of instructions written in HTML(HyperText Markup Language). All browsers know how to display HTML page to the client.
Web由数十亿个通过有线和无线网络连接的客户端和服务器组成。 Web客户端向Web服务器发出请求。 Web服务器接收请求,找到资源并将响应返回给客户端。 服务器回答请求时,通常会向客户端发送某种类型的内容。 客户端使用Web浏览器将请求发送到服务器。 服务器通常使用一组用HTML(超文本标记语言)编写的指令将响应发送到浏览器。 所有浏览器都知道如何向客户端显示HTML页面。
Web应用程序 (Web Application)
A website is a collection of static files(webpages) such as HTML pages, images, graphics etc. A Web application is a web site with dynamic functionality on the server. Google, Facebook, Twitter are examples of web applications.
网站是静态文件(网页)的集合,例如HTML页面,图像,图形等。Web应用程序是在服务器上具有动态功能的网站。 Google , Facebook , Twitter是Web应用程序的示例。
HTTP(超文本传输协议) (HTTP (Hypertext Transfer Protocol))
- HTTP is a protocol that clients and servers use on the web to communicate. HTTP是客户端和服务器在Web上用于通信的协议。
- It is similar to other internet protocols such as SMTP(Simple Mail Transfer Protocol) and FTP(File Transfer Protocol) but there is one fundamental difference. 它类似于其他Internet协议,例如SMTP(简单邮件传输协议)和FTP(文件传输协议),但有一个根本区别。
- stateless protocol i.e HTTP supports only one request per connection. This means that with HTTP the clients connect to the server to send one request and then disconnects. This mechanism allows more users to connect to a given server over a period of time.无状态协议,即HTTP每个连接仅支持一个请求。 这意味着客户端使用HTTP连接到服务器以发送一个请求,然后断开连接。 此机制允许更多用户在一段时间内连接到给定服务器。
- The client sends an HTTP request and the server answers with an HTML page to the client, using HTTP. 客户端使用HTTP向客户端发送HTTP请求,然后服务器向客户端发送HTML页面。
HTTP方法 (HTTP Methods)
HTTP request can be made using a variety of methods, but the ones you will use most often are Get and Post. The method name tells the server the kind of request that is being made, and how the rest of the message will be formated.
可以使用多种方法发出HTTP请求,但是您最常使用的方法是Get和Post 。 方法名称告诉服务器正在发出的请求的类型,以及如何格式化消息的其余部分。
HTTP Methods and Descriptions :
HTTP方法和说明:
| OPTIONS | Request for communication options that are available on the request/response chain. |
| GET | Request to retrieve information from server using a given URI. |
| HEAD | Identical to GET except that it does not return a message-body, only the headers and status line. |
| POST | Request for server to accept the entity enclosed in the body of HTTP method. |
| DELETE | Request for the Server to delete the resource. |
| CONNECT | Reserved for use with a proxy that can switch to being a tunnel. |
| PUT | This is same as POST, but POST is used to create, PUT can be used to create as well as update. It replaces all current representations of the target resource with the uploaded content. |
| 选件 | 请求在请求/响应链上可用的通信选项。 |
| 得到 | 请求使用给定URI从服务器检索信息。 |
| 头 | 与GET相同,除了它不返回消息正文,仅返回标头和状态行。 |
| 开机自检 | 请求服务器接受HTTP方法主体中包含的实体。 |
| 删除 | 请求服务器删除资源。 |
| 连接 | 保留供可切换为隧道的代理使用。 |
| 放 | 这与POST相同,但是POST用于创建,PUT可用于创建和更新。 它用上载的内容替换目标资源的所有当前表示形式。 |
GET和POST请求之间的区别 (Difference between GET and POST requests)
| Data is sent in header to the server | Data is sent in the request body |
| Get request can send only limited amount of data | Large amount of data can be sent. |
| Get request is not secured because data is exposed in URL | Post request is secured because data is not exposed in URL. |
| Get request can be bookmarked and is more efficient. | Post request cannot be bookmarked. |
| 数据以标头发送到服务器 | 数据在请求正文中发送 |
| 获取请求只能发送有限数量的数据 | 可以发送大量数据。 |
| 获取请求不安全,因为数据在URL中公开 | 发布请求受到保护,因为数据未在URL中公开。 |
| 获取请求可以加上书签,效率更高。 | 发布请求无法添加书签。 |
PUT和POST方法之间的一般区别 (General Difference between PUT and POST methods)
Following are some basic differences between the PUT and the POST methods :
以下是PUT和POST方法之间的一些基本区别:
- POST to a URL creates a child resource at a server defined URL while POST到URL会在服务器定义的URL处创建子资源,而PUT to a URL creates/replaces the resource in its entirety at the client defined URL.PUT到URL会在客户端定义的URL处整体创建/替换资源。
-
/bookswill create a resources that will live under the/books将创建一个资源,该资源将位于/booksresource. Eg./books资源下。 例如。/books/1. Sending the same post request twice will create two resources./books/1。 两次发送相同的帖子请求将创建两个资源。 - PUT is for creating or replacing a resource at a URL known by the client. PUT用于在客户端已知的URL处创建或替换资源。
- PUT must be used for CREATE when the client already knows the url before the resource is created. 当客户端在创建资源之前已经知道该URL时,必须将PUT用于CREATE。
- idempotent.幂等的。
HTTP GET请求剖析 (Anatomy of an HTTP GET request)
Get request contains path to server and the parameters added to it.
获取请求包含服务器的路径以及添加到其中的参数。
HTTP POST请求的剖析 (Anatomy of an HTTP POST request)
Post requests are used to make more complex requests on the server. For instance, if a user has filled a form with multiple fields and the application wants to save all the form data to the database. Then the form data will be sent to the server in POST request body, which is also known as Message body.
发布请求用于在服务器上发出更复杂的请求。 例如,如果用户使用多个字段填写了表单,而应用程序希望将所有表单数据保存到数据库中。 然后,表单数据将通过POST请求正文(也称为消息正文)发送到服务器。
翻译自: https://www.studytonight.com/servlet/introduction-to-web.php
web servlet