Servlet + JSP (1): http protocol details

Galloping snail 2020-11-13 02:16:16
servlet jsp http protocol details


Servlet+JSP( One ):HTTP protocol

The development of the Internet is very fast , But everything is the same . Study web Development , We need to be right about We have a certain understanding of the interaction mechanism of the Internet . In order to better understand and master Servlet, In formal study Servlet You need to be right about web The interaction mechanism between client and server in the development and the specifications involved (HTTP) To study .

HTTP protocol

1、 web The basic process of interaction

  Picture introduction :
The client requests the server according to the address information entered by the user , The server is receiving users After the request is processed , Then the processing results are responded to the client , The client presents the response results to the user .

Professional term :

request : The client sends data to the server according to the user address information

Respond to : The process by which the server sends the processing result of a request to the browser

problem :
There are many versions of the client, that is, the browser , There are many versions of the server Of , How to realize the data interaction between different versions of browsers and different versions of servers ?

solve :
Standardize the format of data interaction between browser and server .

Realization :HTTP agreement

2、 HTTP The concept and introduction of

Concept :
Hypertext transfer protocol (Hyper Text Transfer Protocol)
effect :
It standardizes the data interaction between browser and server
characteristic :
Simple and fast : When a client requests a service from the server , Just send the request method and path . The common request methods are GET、HEAD、POST. Each method specifies a different type of client server contact . because HTTP Simple protocol , bring HTTP The program size of the server is small , So communication is fast
flexible :HTTP Allow transfer of any type of data object . The type being transmitted is by Content-Type To mark .
There is no connection : Connectionless means that you are limited to one request per connection . The server completes the client's request , And received the customer's response , disconnect . This way you can save transmission time .
No state :HTTP A protocol is a stateless protocol . Stateless is a protocol that has no memory for transactions . The lack of state means that the previous information is required for subsequent processing , It must be retransmitted , This can lead to an increase in the amount of data transferred per connection . On the other hand , The server responds quickly when it does not need the previous information .

Support B/S And C/S Pattern .
HTTP1.1 Support sustainable connectivity after the release

3、 HTTP The interaction process of :

HTTP There are four steps in the interaction process ( A complete request ): Step one : Establish connection between client and server Step two : Client sends request data to server (HTTP agreement ) Step three : After the server receives the request , To deal with , And then Processing results respond to the client (HTTP agreement ) Step four : Close the connection between the client and the server (HTTP1.1 It won't shut down immediately after )

4、 HTTP Form of request for agreement

The structure of the request format : Request header : Request mode 、 Requested address and HTTP Protocol version Request line : The message header , It is generally used to indicate some additional information to be used by the client Blank line : Between the request line and the request data , It's necessary to have an empty line . Request data : Not necessary .

Be careful : The content of a web page is extremely rich , Browsers follow HTTP The format of the request sends valid data to the server .

 5、 HTTP The way the agreement is requested

according to HTTP standard ,HTTP Multiple request methods can be used for requests .

HTTP1.0 Three request methods are defined : GET, POST and HEAD Method .

HTTP1.1 Five new request methods :OPTIONS,PUT,DELETE,TRACE and CONNECT Method .

get and post Difference in request mode :

get Request mode : The request data will be ? In the request header , unsafe , No, please be realistic The body part . HTTP Although the protocol does not specify the size of the request data , But the browser is right URL Length There is a limit to the degree , therefore get Requests can't carry a lot of data . 

post Request mode : Request data is sent in the requesting entity , stay URL No specific request data can be found in , Security . It is suitable for sending large amount of data .

6、HTTP Response to the agreement

The structure of the response format : Response line ( Status line ):HTTP edition 、 Status code 、 Status message Response head : The message header , Additional information used by the client Blank line : Between the response header and the response entity , necessary . In response to the entity : Text , Information returned by the server to the browser
Example :

HTTP Common response status code meaning : HTTP The status code consists of three decimal digits , The first decimal number defines the status code The type of , The last two numbers have no role in classification .HTTP Status codes are divided into 5 Types :

Common status code :

200 OK // Client request successful

400 Bad Request // Client request has syntax error , Can't be handled by the server Explain

401 Unauthorized // Request not authorized , The status code must be equal to WWW-Authenticate Header fields are used together

403 Forbidden // The server receives the request , But refused to provide service

404 Not Found // The requested resource does not exist ,eg: I typed the wrong one URL

500 Internal Server Error // An unexpected error occurred on the server

503 Server Unavailable // The server is currently unable to process the client's request , It may return to normal after some time  

 

版权声明
本文为[Galloping snail]所创,转载请带上原文链接,感谢

  1. [front end -- JavaScript] knowledge point (IV) -- memory leakage in the project (I)
  2. This mechanism in JS
  3. Vue 3.0 source code learning 1 --- rendering process of components
  4. Learning the realization of canvas and simple drawing
  5. gin里获取http请求过来的参数
  6. vue3的新特性
  7. Get the parameters from HTTP request in gin
  8. New features of vue3
  9. vue-cli 引入腾讯地图(最新 api,rocketmq原理面试
  10. Vue 学习笔记(3,免费Java高级工程师学习资源
  11. Vue 学习笔记(2,Java编程视频教程
  12. Vue cli introduces Tencent maps (the latest API, rocketmq)
  13. Vue learning notes (3, free Java senior engineer learning resources)
  14. Vue learning notes (2, Java programming video tutorial)
  15. 【Vue】—props属性
  16. 【Vue】—创建组件
  17. [Vue] - props attribute
  18. [Vue] - create component
  19. 浅谈vue响应式原理及发布订阅模式和观察者模式
  20. On Vue responsive principle, publish subscribe mode and observer mode
  21. 浅谈vue响应式原理及发布订阅模式和观察者模式
  22. On Vue responsive principle, publish subscribe mode and observer mode
  23. Xiaobai can understand it. It only takes 4 steps to solve the problem of Vue keep alive cache component
  24. Publish, subscribe and observer of design patterns
  25. Summary of common content added in ES6 + (II)
  26. No.8 Vue element admin learning (III) vuex learning and login method analysis
  27. Write a mini webpack project construction tool
  28. Shopping cart (front-end static page preparation)
  29. Introduction to the fluent platform
  30. Webpack5 cache
  31. The difference between drop-down box select option and datalist
  32. CSS review (III)
  33. Node.js学习笔记【七】
  34. Node.js learning notes [VII]
  35. Vue Router根据后台数据加载不同的组件(思考->实现->不止于实现)
  36. Vue router loads different components according to background data (thinking - & gt; Implementation - & gt; (more than implementation)
  37. 【JQuery框架,Java编程教程视频下载
  38. [jQuery framework, Java programming tutorial video download
  39. Vue Router根据后台数据加载不同的组件(思考->实现->不止于实现)
  40. Vue router loads different components according to background data (thinking - & gt; Implementation - & gt; (more than implementation)
  41. 【Vue,阿里P8大佬亲自教你
  42. 【Vue基础知识总结 5,字节跳动算法工程师面试经验
  43. [Vue, Ali P8 teaches you personally
  44. [Vue basic knowledge summary 5. Interview experience of byte beating Algorithm Engineer
  45. 【问题记录】- 谷歌浏览器 Html生成PDF
  46. [problem record] - PDF generated by Google browser HTML
  47. 【问题记录】- 谷歌浏览器 Html生成PDF
  48. [problem record] - PDF generated by Google browser HTML
  49. 【JavaScript】查漏补缺 —数组中reduce()方法
  50. [JavaScript] leak checking and defect filling - reduce() method in array
  51. 【重识 HTML (3),350道Java面试真题分享
  52. 【重识 HTML (2),Java并发编程必会的多线程你竟然还不会
  53. 【重识 HTML (1),二本Java小菜鸟4面字节跳动被秒成渣渣
  54. [re recognize HTML (3) and share 350 real Java interview questions
  55. [re recognize HTML (2). Multithreading is a must for Java Concurrent Programming. How dare you not
  56. [re recognize HTML (1), two Java rookies' 4-sided bytes beat and become slag in seconds
  57. 【重识 HTML ,nginx面试题阿里
  58. 【重识 HTML (4),ELK原来这么简单
  59. [re recognize HTML, nginx interview questions]
  60. [re recognize HTML (4). Elk is so simple