zoukankan      html  css  js  c++  java
  • Java开发工程师(Web方向)

    第1章--Web应用开发概述

    Web应用开发概述

    浏览器-服务器架构(BS-architecture)

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

                           <- response/data --

    protocol: HTTP(Hyper-Text Transfer Protocol)

     

    have a try:

    cmd: sudo nc -l 80  -- listen at the port of 80(port 80 is used by HTTP)

    browser: type "localhost" in the address bar

    these are the info that sent to the server(localhost)

    meanwhile, the browser is waiting for the request (from the server)

    try to type "hello" and ctrl+c

    "hello" will be displayed in the browser

     

    If we enter the address of a website, such as "http://study.163.com"

    it is called URL (uniform resource locator) (统一资源定位)

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

    http: protocol, such as ftp, mailto

    smartSpec/intro.html: request sent to the server

    ?name=163: data that sent to the server via GET method

    Let's see what info can be sent via GET method

     [html] view plain copy

      1. <html> <body>  
      2. <form action="http://localhost/form_action.html" method="get">  
      3. <p>First Name: <input type="text" name="fname" /></p>  
      4. <p>Last Name: <input type="text" name="lname" /></p>  
      5. <input type="submit" value="Submit" />  
      6. </form> </body> </html>  

    1. open .html in the browser

    2. type sudo nc -l 80 in terminal

    3. submit the info

    4. result

    GET /form_action.html?fname=Lin&lname=Matt

    What if we use POST as the method?

    same steps as GET

    but different result:

    POST /form_action.html (no extra data shown explicitly after "/form_action.html")

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

    furthermore, new property "content-length" added, which means the number of characters (data) sent to the server, which is fname=Lin&lname=Matt in this case)

     

    After those info/data/request(shown above) has been sent to the server,

    the server needs to give the feedback(response) back to the client/ browser.

    feedback:

    1. 静态页面(such as .html file, .img file)

         2. 动态数据  (data retrieved by programs running on the server side based on the input (like first name/ last name in the previous example))

     

    HTTP protocol: connectionless 无连接的

    After a series of actions has done (request --> response),the connection gets broken.

    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会话 (session) :connection, request, response, close.

     

    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

  • 相关阅读:
    c#语法基础(2)——运算符重载
    c#语法基础(1):关键字
    halcon与C#混合编程(一)打开一张图片
    vc中判断excel、word文件是否存在,删除excel文件
    officeView.obj : error LNK2001: unresolved external symbol __imp__PathFileExistsA@4
    VC单选按钮控件(Radio Button)用法
    FNN模糊神经网络——信息系统客户服务感知评价
    《MATLAB数据分析与挖掘实战》赠书活动
    RBF径向基神经网络——乳腺癌医学诊断建模
    基于关联规则的电子商务智能推荐服务--实例讲解
  • 原文地址:https://www.cnblogs.com/FudgeBear/p/7229030.html
Copyright © 2011-2022 走看看