Servlet学习

HTTP Requests

The request sent by the computer to a web server, contains all sorts of potentially interesting information; it is known as HTTP requests.

The HTTP client sends the request to the server in the form of request message which includes following information:

  • The Request-line
  • The analysis of source IP address, proxy and port
  • The analysis of destination IP address, protocol, port and host
  • The Requested URI (Uniform Resource Identifier)
  • The Request method and Content
  • The User-Agent header
  • The Connection control header
  • The Cache control header

The HTTP request method indicates the method to be performed on the resource identified by the Requested URI (Uniform Resource Identifier). This method is case-sensitive and should be used in uppercase.

The HTTP request methods are:

HTTP RequestDescription
GETAsks to get the resource at the requested URL.
POSTAsks the server to accept the body info attached. It is like GET request with extra info sent with the request.
HEADAsks for only the header part of whatever a GET would return. Just like GET but with no body.
TRACEAsks for the loopback of the request message, for testing or troubleshooting.
PUTSays to put the enclosed info (the body) at the requested URL.
DELETESays to delete the resource at the requested URL.
OPTIONSAsks for a list of the HTTP methods to which the thing at the request URL can respond
HTTP请求的描述
GET要求在被请求的URL中获取资源。
POST要求服务器接受附加的身体信息。这就像GET请求中带有请求的额外信息一样。
HEAD只要求返回的标题部分。就像得到,但没有身体。
TRACE询问请求消息的回环,用于测试或故障排除。
PUT说将所包含的信息(主体)放在所请求的URL中。
DELETE说要在请求的URL中删除资源。
选项要求提供一个HTTP方法的列表,其中请求URL中的东西可以响应
====================================

Get vs. Post

There are many differences between the Get and Post request. Let's see these differences:

GETPOST
1) In case of Get request, only limited amount of data can be sent because data is sent in header.In case of post request, large amount of data can be sent because data is sent in body.
2) Get request is not secured because data is exposed in URL bar.Post request is secured because data is not exposed in URL bar.
3) Get request can be bookmarked.Post request cannot be bookmarked.
4) Get request is idempotent . It means second request will be ignored until response of first request is deliveredPost request is non-idempotent.
5) Get request is more efficient and used more than Post.Post request is less efficient and used less than get.

Get和Post请求之间有许多区别。让我们看看这些差异:
得到后
1)在得到请求的情况下,由于数据是在头中发送的,所以只能发送有限的数据。在post请求的情况下,可以发送大量的数据,因为数据是在正文中发送的。
2)Get请求没有被保护,因为数据是在URL栏中公开的。Post请求是安全的,因为数据不会在URL栏中公开。
3)Get请求可以被标记。Post请求不能被标记。
4)Get请求是幂等的。这意味着第二个请求将被忽略,直到第一个请求的响应被发送后请求是非幂的。
5)Get请求比Post更有效,使用更多。Post请求的效率较低,使用的效率也较低。

GET and POST

Two common methods for the request-response between a server and client are:

  • GET- It requests the data from a specified resource
  • POST- It submits the processed data to a specified resource
服务器和客户机之间的请求-响应的两种常见方法是:
GET-它请求来自指定资源的数据
POST——它将处理过的数据提交给指定的资源

Anatomy of Get Request

The query string (name/value pairs) is sent inside the URL of a GET request:

  1. GET /RegisterDao.jsp?name1=value1&name2=value2  

As we know that data is sent in request header in case of get request. It is the default request type. Let's see what information is sent to the server.

Servlet Request6

Some other features of GET requests are:

  • It remains in the browser history
  • It can be bookmarked
  • It can be cached
  • It have length restrictions
  • It should never be used when dealing with sensitive data
  • It should only be used for retrieving the data
GET请求的其他一些特性是:
它仍然存在于浏览器历史中
它可以是书签
它可以被缓存
它有长度限制
在处理敏感数据时不应该使用它
它应该只用于检索数据

Anatomy of Post Request

The query string (name/value pairs) is sent in HTTP message body for a POST request:

  1. POST/RegisterDao.jsp HTTP/1.1  
  2. Host: www. javatpoint.com  
  3. name1=value1&name2=value2  

As we know, in case of post request original data is sent in message body. Let's see how information is passed to the server in case of post request.


Some other features of POST requests are:

  • This requests cannot be bookmarked
  • This requests have no restrictions on length of data
  • This requests are never cached
  • This requests do not retain in the browser history
POST请求的其他一些特性是:
这些请求不能被标记为书签
这些请求对数据的长度没有限制
这些请求永远不会被缓存
这些请求不会在浏览器历史中保留
==========================================================


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值