01.Java Web开发入门 - 第1章.Web应用开发概述

转载自https://www.cnblogs.com/FudgeBear,他的课堂笔记很好,为了加深记忆,我也在word中跟着重新打了一遍。

Web应用开发概述

浏览器-服务器架构 bs-architecture

browser/app -> request ->server(database)

                     <- response/data --

  protocol :HTTP (Hype-text transfer protocol) 

have a try:

打开terminal,输入sudo nc –l 8089

然后在浏览器中输入localhost:8089,terminal中就出现请求头信息。

然后在terminal中输入hello,按下crtl c,浏览器里就会出现hello.(我这里没有出现,不知道原因。)

 

In this case: "http://study.163.com/smartSpec/intro.html?name=163"

Http:// 是 protocol, others like ftp mailto

Study.163.com url (uniform resource locator)

smartSpec/intro.html 是发送的请求向服务器

?name=163 向服务器发送的数据,通过get方法

 

Get method  “/form_action.html?fname=Lin&lname=Matt”

POST method "fname=Lin&lname=Matt" will be displayed at the end.

 

HTTP protocol: connectionless 无连接的

Advantages --> disconnect with those users who are not currently communicating with the server at that time, in other words, accessible to as many users as possible at the same time

Disadvantages: the server does not know who u r after one connection.

for example, after we log in, we expect that we do not need to log in again if we try to visit other relevant webpages.

--> solution: cookie

 after the first-time connection, the client got a "number" from the server which identifies the client/ browser itself.

then the browser will store that number, and every time the client connects to the server, it will bring that number with it, and the server will know the client by checking that id number

that number in this example is called cookie.

Also, the cookie got its own expiry date, which is set by the server.

 

HTTP protocol: how to deal with the data in the database

background: when the client sends a request to the server, the program in the server always try to retrieve the relevant data from its database system, and then the program is going to generate an HTML file (or other file that can be understood by the browser), and sends back to the client as a response.

problem 1: the limitation of the number of connections between the database and the web server is much smaller than that between the client and the web server.

in other words, minimising the number of the connections btw database and the web server is required.

--> solution1: connection pool

creates a connection pool between the web server and the database which has limited connections.

each time the web server requires a connection to the database, it will ask the connection pool for the access of connection

--> solution2: cache

different clients might search for the same data during a short period of time

there is no need to run the program to retrieve the same data from the database repeatedly.

-- lower the workload of the database and speed up the reaction from the server

 

猜你喜欢

转载自blog.csdn.net/liujingjie2010/article/details/82875792