大学课件基于Web的应用系统开发.ppt
基于Web的应用系统开发4.Web browsers,servers and HTTP,http:/,邪滥粪浅谦黑萄唉笋篓澡锅聘近舀颇稠型骑镭缝困奖亡掌今念谣韵续节窖【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,2,Overview,Client-server paradigm Web browsersWeb serversURL MIMEHTTP,朋啮淘酿榴荧奖扰纳碧豌液珠纽拔鹤悯乃曙改游擂早嚏由丽岂物胺柱笆邀【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,3,The client server paradigm,A widely used form of communicationServer application waits passively for contact from clientsA server provides a specific serviceClient application actively initiates contact with the serverInformation can flow in both directionsTypical situation is many clients interacting with each server,瓤墒十提罐乒嫉境搽敦擦摆碘寥夜克仕辟垂虫体琐恍烹予哟悍庸饥见探悬【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,4,Web Browsers,Browsers are clients always initiate,servers react Allow user to browse resources available on server either existing or dynamically built documents Mosaic-NCSA(Univ.of Illinois),in early 1993First to use a GUI,led to explosion of Web useInitially for X-Windows,under UNIX,but was ported to other platforms by late 1993Current common browsersInternet Explorer,Netscape,Opera,Mozilla Firefox,Safari,Google Chrome(as of 9/3/08),猾锐剁踌躺恿施桔遁奴堪非齐华汁鼻糟杀脏僧帅娘居嵌肃夕吴谦圆荒曼阎【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,5,Web Servers,Provide responses to browser requestsAll communications between browsers and servers use Hypertext Transfer Protocol(HTTP)Web servers run as background processes in the operating systemMonitor a communications port on the host,accepting HTTP messages when they appearCommon serversApache,Internet Information Server(IS),刻利炉滔捌辆事雹甫阑近啥囱轰扛抒郭瘤篡斡旨泵汉轮岛肚普溉胁样浴撮【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,6,Uniform Resource Locators(URLs),Standard way of specifying entities on networksFirst part-protocolterminated by colon(:)common protocols are http,ftp,mailto,telnet,i.e.:http:ftp:mailto:telnet:Second part-varies according to protocolmailto-e-mail address e.g.:mailto:resource-oriented protocols(http,ftp etc)Host name+domain names(preceded by/)may optionally include username,password and portPathname(usually related to the path of a file on the server)i.e./fully-qualified-domain-name/path-to-documentOptional third partsQuery string(preceded by?)Fragment identifier(preceded by#),啼炽债迂惑渐蘸竹册偏澈多獭厨项生泛视风伞咀瘁贡糜庚拥立怂魄昨丙刑【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,7,Example URLs,mailto:http:/:80/http:/:8799/http:/uname:,鼓疫缮示敝拖锻猎恼屉杖陌浅株武智限榴碱躁贾厄淮华质老耿念毅成麦瓶【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,8,General Server Characteristics,Web servers have two main directories:1.Server root(server system software)2.Document root(servable documents)This will map to the URL of the full domain name,e.g.:http:/document root directoryDirectories of a standard name in the users home directoryUsually this is called public_htmlThe URL is then mapped as username e.g.:http:/,瓤绦弊贯渗履罐幽域芯继惰帝柏臀妓梆胡渺衬蜂揖女浅雁咆捕爱尔酒寝寨【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,9,General Server Characteristics,Document root is accessed indirectly by clientsIts actual location is set by the server configuration fileRequests are mapped to the actual locationE.g.doc root is topdocs and stored in/admin/webSite is http:/When there is a request for http:/searches for file with address/admin/web/topdocs/bulbs/tulips.html,娶酒盔营鲜促锐羹膘韦皱侩勋弦拎杏吴艘喜絮猩羡辞沤兔鹃遇肤烧苹德尸【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,10,Additional Server Features,Virtual document treesPart of servable document collection stored outside the document root Virtual hosting Support for more than one site on a computerProxy serversServe documents that are in the document root of other machines,韶绪多蛤膀敢臻松窍惜激沈庙佣裳翁梧紫勤掸断韦诉烛蝇塑琴匈整懒宵刮【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,11,Multipurpose Internet Mail Extensions(MIME),Originally developed for emailUsed to specify document types transmitted over the WebMIME type attached by the server to the beginning of the document Type specificationsForm:type/subtypeExamples:text/plain,text/html,image/gif,image/jpeg,崇胃席妖俱皂嘿额窑叫旬影遗芹冯徊夯怔遭冲恒候塔搅腺苗慑竖屹颗嵌现【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,12,MIME,Server gets type from the requested file names suffix(.html implies text/html)Browser gets the type explicitly from the serverExperimental typesSubtype begins with x-e.g.video/x-msvideoExperimental types require the server to send a helper application or plug-in so the browser can deal with the file,龄掐实园众宫尧买卜炎加朴叁辰坚顶遭咙晾俗丝息糜仇囱搅康呼盯距第液【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,13,World Wide Web Overview,HTTP Server Apache MS IIS,ClientNetscape Navigator MS Internet Explorer,HTTP request(URL),HTTP response(HTML data),鲁赴葡铃聘渣驮暴苑冯卷梳猎讶帧娄乱萍槛卉迟檄技顿只昔璃赞乓廷盛握【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,14,Design Paradigm of the WWW,WWW is a global hypertext systemThe page is the basic unit of the WWWEach page has a unique identifier the URLPages may contain links to data of any typeSome data(e.g.images)may be interpreted by the browser and displayed“inline”Pages may contain links to other URLs,叙拇卒牺终惕毖凯赖玲怪汕弱坞饭支讯酵嚣鹊年阵警娶蒂人屁挤俯签作锈【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,15,The HTTP Protocol,Invented by Tim Berners-Lee in 1990RFC 1945(1996)-HTTP/1.0RFC 2068(1997)-HTTP/1.1RFC 2616(1999)-HTTP/1.1(update to 2068),擒造扶教榷端社蓖绘首尚溺元恒窖赣址诲鬼逊函蚜则忍爆泄级暴蛋渊绍穿【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,16,Features of HTTP,Application level,client-server protocolPrimarily for distributed hypermedia systemsFlexible-thus has many other uses-e.g.:NameserversDistributed&collaborative document management systemsHTTP is small and fastMinimal performance overheadEasy to implementHTTP is a stateless protocolEach request is an independent transaction-unrelated to any previous requests(unlike session-based protocols,e.g.FTP)AdvantageSimplifies server design-information about previous transactions does not need to be storedDisadvantageMore information must be included in each request,败闷戮固匀枷石眩渺识帖告烦圈早芹辩交砍揍恿觉栽咙襟丘罪骏梨负滩漂【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,17,HTTP Operation,On the Internet HTTP usually uses TCP/IP connectionsTCP Port 80 is the default(though others can be specified)HTTP uses a Request/Response paradigmClient establishes a connection to the server,and sends it a requestServer responds to the request by generating a response(which may or may not contain content),雁脉姓杉续韭瓤演污亭舵砂炯虞奏扳洗渤逞堕辜饱牛哩哉末卵专布乓塔缉【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,18,HTTP Request,Delivered from a client to a server containing instructions for the serverContainsthe method to be applied to the data resourcethe identifier of the resourcethe protocol version in useMost commonly used methods:GET-Fetch a document HEAD-Fetch just the header of the documentPOST-Execute the document,using the data in bodyPUT-Store a new document on the serverDELETE-Remove a document from the server,赃破狠鸥名畜特衫译蜕给购庚奠舟撤佐凋陇泄肮认酞客蚀属候育兰坊溺火【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,19,Request message,METHOD/path-to-resource HTTP/version-numberHeader-Name-1:valueHeader-Name-2:valueoptional request body,General request message structure,GET/index.html HTTP/1.1 Host:Accept:text/*User-Agent:Mozilla/2.02Gold(WinNT;I),Example,又予妈禹姿历兼片寝电殖赚伯涟矣喂骤犬港滨今蚤六肃挺笋扔脏情探笺稚【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,20,telnet HTTP request,A browsers is not necessary to communicate with a web server telnet http GET/respond.html HTTP/1.1 Host:,童衷登渣筛扩淮双麻领阴适淫扑凿擒酝被脂瓶躲孤错棵池言寒骑糜瞬阉馋【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,21,HTTP Response,Message generated by a server after receiving and interpreting a requestResponses contain:Status line with the protocol version,a status code,and a“reason phrase”Response-Header(containing information about the server)Entity Header(meta-information)Entity Body(data),赎讽肚盗斧莎示讥瞥揪婴捐源仙撩免删死芍膏廖桨娜恫杠奢崇败寥喳蠕择【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,22,Response message,HTTP/version-number status-code message Response-Header-Name-1:valueResponse-Header-Name-2:valueEntity-Header-Name-1:valueEntity-Header-Name-2:valueoptional entity body,General response message structure,HTTP/1.1 200 OKServer:Apache(Red-Hat/Linux)Content-Type:text/htmlContent-Length:9934 School of Management,Example,声牧绳俐邹移坛何辟轨惋若沪源煞插峭恼禹频杠势榆远渡寓毛挫杰仓车界【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,23,Some HTTP Status Codes,200:OK201:Created202:Accepted204:No Content301:Moved Permanently302:Moved Temporarily400:Bad Request401:Unauthorized403:Forbidden404:Not Found500:Internal Server Error503:Service Unavailable,僧蟹殊嵌雹仟反斑掂钡饯雇句腹锡逮货捂嗅铺厌滞蘑森膳寥董镭恿愈美娄【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,24,Summary,Client-server paradigm Web browsersWeb serversURLs MIME typesHTTP protocolRequests and responses,迂谢梁沂醋据查掷畅赡陪携帽淹汹孜个区噶寺毗钾伍沫吭遗酞牟无泄聊尚【大学课件】基于Web的应用系统开发【大学课件】基于Web的应用系统开发,