高校學(xué)生公寓管理系統(tǒng)_外文翻譯(范文)_第1頁
高校學(xué)生公寓管理系統(tǒng)_外文翻譯(范文)_第2頁
高校學(xué)生公寓管理系統(tǒng)_外文翻譯(范文)_第3頁
高校學(xué)生公寓管理系統(tǒng)_外文翻譯(范文)_第4頁
高校學(xué)生公寓管理系統(tǒng)_外文翻譯(范文)_第5頁
已閱讀5頁,還剩15頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、 外文文獻(xiàn)資料http and servlet basicslets start off this chapter by defining the term web application. weve all seen regular client-side applications, but what exactly is a web application? loosely, it can be defined as an application running on a server a user accesses through a thin, general-purpose clie

2、nt. today, the most common client is a web browser on a pc or workstation, but other kinds of clients are rapidly joining the party, such as wireless pdas, cell phones, and other specialized devices.the lofty goal here is to access all the information and services you need from any type of device th

3、at happens to be in front of you. this means that the same simple client program must be able to talk to many different server applications, and the applications must be able to work with many different types of clients. to satisfy this need, the protocol of how a client and a server talk to each ot

4、her must be defined in detail. thats exactly what the hypertext transport protocol (http) is for.the communication model defined by http forms the foundation for all web application design. a basic understanding of http is key to developing applications that fit within the constraints of the protoco

5、l, no matter which server-side technology you use. in this chapter, we look at the most important details of http you need to be aware of as a web application developer.one other item: this book is about using jsp as the server-side technology. jsp is based on the java servlet technology. both techn

6、ologies share a lot of terminology and concepts, so knowing a bit about servlets will help you even when you develop pure jsp applications. to really understand and use the full power of jsp, you need to know a fair bit about servlets. hence, we look at servlet fundamentals in the last section of th

7、is chapter.2.1 the http request/response modelhttp and all extended protocols based on http are based on a very simple communications model. heres how it works: a client, typically a web browser, sends a request for a resource to a server, and the server sends back a response corresponding to the re

8、source (or a response with an error message if it cant process the request for some reason). a resource can be a number of things, such as a simple html file returned verbatim to the browser or a program that generates the response dynamically. this simple model implies three important facts you nee

9、d to be aware of:http is a stateless protocol. this means that the server doesnt keep any information about the client after it sends its response, and therefore it cant recognize that multiple requests from the same client may be related.web applications cant easily provide the kind of immediate fe

10、edback typically found in standalone gui applications such as word processors or traditional client/server applications. every interaction between the client and the server requires a request/response exchange. performing a request/response exchange when a user selects an item in a list box or fills

11、 out a form element is usually too taxing on the bandwidth available to most internet users.theres nothing in the protocol that tells the server how a request is made; consequently, the server cant distinguish between various methods of triggering the request on the client. for example, http doesnt

12、allow a web server to differentiate between an explicit request caused by clicking a link or submitting a form and an implicit request caused by resizing the browser window or using the browsers back button. in addition, http doesnt contain any means for the server to invoke client specific function

13、s, such as going back in the browser history list or sending the response to a certain frame. also, the server cant detect when the user closes the browser.over the years, people have developed various tricks to overcome the first problem; https stateless nature. the other two problemsno immediate f

14、eedback and no details about how the request is madeare harder to deal with, but some amount of interactivity can be achieved by generating a response that includes client-side code (code executed by the browser), such as javascript or a java applet. 2.1.1 requests in detaillets take a closer look a

15、t requests. a user sends a request to the server by clicking a link on a web page, submitting a form, or typing in a web page address in the browsers address field. to send a request, the browser needs to know which server to talk to and which resource to ask for. this information is specified by an

16、 http uniform resource locator (url):the first part of the url shown specifies that the request is made using the http protocol. this is followed by the name of the server, in this case . the web server waits for requests to come in on a specific tcp/ip port. port number 80 is the standard port for

17、http requests. if the web server uses another port, the url must specify the port number in addition to the server name. for example:8080/index.htmlthis request is sent to a server that uses port 8080 instead of 80. the last part of the url, /index.html, identifies the resource that the client is re

18、questing.a url is actually a specialization of a uniform resource identifier (uri, defined in the rfc-2396 specification). a url identifies a resource partly by its location, for instance the server that contains the resource. another type of uri is a uniform resource name (urn), which is a globally

19、 unique identifier that is valid no matter where the resource is located. http deals only with the url variety. the terms uri and url are often used interchangeable, and unfortunately, they have slightly different definitions in different specifications. im trying to use the terms as defined by the

20、http/1.1 specification (rfc-2616), which is pretty close to how they are also used in the servlet and jsp specifications. hence, i use the term url only when the uri must start with http (or https, for http over an encrypted connection) followed by a server name and possibly a port number, as in the

21、 previous examples. i use uri as a generic term for any string that identifies a resource, where the location can be deduced from the context and isnt necessarily part of the uri. for example, when the request has been delivered to the server, the location is a given, and only the resource identifie

22、r is important.the browser uses the url information to create the request message it sends to the specified server using the specified protocol. an http request message consists of three things: a request line, request headers, and possibly a request body.the request line starts with the request met

23、hod name, followed by a resource identifier and the protocol version used by the browser:get /index.html http/1.1the most commonly used request method is named get. as the name implies, a get request is used to retrieve a resource from the server. its the default request method, so if you type a url

24、 in the browsers address field, or click on a link, the request is sent as a get request to the server.the request headers provide additional information the server may use to process the request. the message body is included only in some types of requests, like the post request discussed later.here

25、s an example of a valid http request message:get /index.html http/1.1host: user-agent: mozilla/5.0 (windows; u; win 9x 4.90; en-us; rv: 1.0.2)accept: image/gif, image/jpeg, image/pjpeg, image/png, */*accept-language : enaccept-charset : iso-8859-1,*,utf-8the request line specifies the get method and

26、 asks for the resource named /index.html to be returned using the http/1.1 protocol version. the various headers provide additional information.the host header tells the server the hostname used in the url. a server may have multiple names, so this information is used to distinguish between multiple

27、 virtual web servers sharing the same web server process.the user-agent header contains information about the type of browser making the request. the server can use this to send different types of responses to different types of browsers. for instance, if the server knows whether internet explorer o

28、r netscape navigator is used, it can send a response that takes advantage of each browsers unique features. it can also tell if a client other than an html browser is used, such as a wireless markup language (wml) browser on a cell phone or a pda device, and generate an appropriate response.the acce

29、pt headers provide information about the languages and file formats the browser accepts. these headers can be used to adjust the response to the capabilities of the browser and the users preferences, such as use a supported image format and the preferred language. these are just a few of the headers

30、 that can be included in a request message. the resource identifier (uri) doesnt necessarily correspond to a static file on the server. it can identify an executable program, a record in a database, or pretty much anything the web server knows about. thats why the generic term resource is used. in f

31、act, theres no way to tell if the /index.html uri corresponds to a file or something else; its just a name that means something to the server. the web server is configured to map these unique names to the real resources.2.1.2 responses in detailwhen the web server receives the request, it looks at t

32、he uri and decides, based on configuration information, how to handle it. it may handle it internally by simply reading an html file from the filesystem, or it can forward the request to some component that is responsible for the resource corresponding to the uri. this can be a program that uses dat

33、abase information, for instance, to dynamically generate an appropriate response. to the browser it makes no difference how the request is handled; all it cares about is getting a response.the response message looks similar to the request message. it consists of three things: a status line, response

34、 headers, and an optional response body. heres an example:http/1.1 200 oklast-modified: mon, 20 dec 2002 23:26:42 gmtdate: tue, 11 jan 2003 20:52:40 gmtstatus: 200content-type: text/htmlservlet-engine: tomcat web server/5.0content-length: 59 hello world! the status line starts with the name of the p

35、rotocol, followed by a status code and a short description of the status code. here the status code is 200, meaning the request was executed successfully. the response message has headers just like the request message. in this example, the last-modified header gives the date and time for when the re

36、source was last modified. the browser can use this information as a timestamp in a local cache; the next time the user asks for this resource, he can ask the server to send it only if its been updated since the last time it was requested. the content-type header tells the browser what type of respon

37、se data the body contains and the content-length header how large it is. the other headers are self-explanatory. a blank line separates the headers from the message body. here the body is a simple html page: hello world! of course, the body can contain a more complex html page or any other type of c

38、ontent. for example, the request may return an html page with elements. when the browser reads the first response and finds the elements, it sends a new request for the resource identified by each element, often in parallel. the server returns one response for each image request, with a content-type

39、 header telling what type of image it is (for instance image/gif) and the body containing the bytes that make up the image. the browser then combines all responses to render the complete page.2.1.3 request parametersbesides the uri and headers, a request message can contain additional information in

40、 the form of parameters. if the uri identifies a server-side program for displaying weather information, for example, request parameters can provide information about the city the user wants to see a forecast for. in an e-commerce application, the uri may identify a program that processes orders, wi

41、th the users customer number and the list of items to be purchased transferred as parameters.parameters can be sent in one of two ways: tacked on to the uri in the form of a query string or sent as part of the request message body. this is an example of a url with a query string:the query string sta

42、rts with a question mark (?) and consists of name/value pairs separated by ampersands (&). these names and values must be url-encoded, meaning that special characters, such as whitespace, question marks, ampersands, and all other nonalphanumeric characters are encoded so that they dont get confused

43、with characters used to separate name/value pairs and other parts of the uri. in this example, the space between hermosa and beach is encoded as a plus sign. other special characters are encoded as their corresponding hexadecimal ascii value; for instance, a question mark is encoded as %3f. when par

44、ameters are sent as part of the request body, they follow the same syntax; url encoded name/value pairs separated by ampersands. 2.1.4 request methodsas described earlier, get is the most commonly used request method, intended to retrieve a resource without causing anything else to happen on the ser

45、ver. the post method is almost as common as get; it requests some kind of processing on the server, for instance, updating a database or processing a purchase order.the way parameters are transferred is one of the most obvious differences between the get and post request methods. a get request alway

46、s uses a query string to send parameter values, while a post request always sends them as part of the body (additionally, it can send some parameters as a query string, just to make life interesting). if you insert a link in an html page using an element, clicking on the link results in a get reques

47、t being sent to the server. since the get request uses a query string to pass parameters, you can include hardcoded parameter values in the link uri: hermosa beach weather forecastwhen you use a form to send user input to the server, you can specify whether to use the get or post method with the met

48、hod attribute, as shown here: city: state: if the user enters hermosa beach and ca in the form fields and clicks on the submit button, the browser sends a request message like this to the server:post /forecast http/1.1host: user-agent: mozilla/5.0 (windows; u; win 9x 4.90; en-us; rv: 1.0.2)accept: i

49、mage/gif, image/jpeg, image/pjpeg, image/png, */*accept-language: en-usaccept-charset: iso-8859-1,*,utf-8city=hermosa+beach&state=cadue to the differences in how parameters are sent by get and post requests, as well as the differences in their intended purpose, browsers handle the requests in differ

50、ent ways. a get request, parameters and all, can easily be saved as a bookmark, hardcoded as a link, and the response cached by the browser. also, the browser knows that no damage is done if it needs to send a get request again automatically, for instance if the user clicks the reload button.a post

51、request, on the other hand, cant be bookmarked as easily; the browser would have to save both the uri and the request message body. since a post request is intended to perform some possibly irreversible action on the server, the browser must also ask the user if its okay to send the request againbes

52、ides the get and post methods, http specifies the following methods:optionsthe options method is used to find out what options (e.g., methods) a server or a resource offers.headthe head method is used to get a response with all headers generated by a get request but without the body. it can make sur

53、e a link is valid or to see when a resource was last modified.putthe put method is used to store the message body content on the server as a resource identified by the uri.deletethe delete method is used to delete the resource identified by the uri.tracethe trace method is used for testing the commu

54、nication between the client and the server. the server sends back the request message, exactly as it received it, as the body of the response.these methods arent normally used in a web application.2.2 servletsthe jsp specification is based on the java servlet specification. in fact, jsp pages are of

55、ten combined with servlets in the same application. in this section, we take a brief look at what a servlet is, and then discuss the concepts shared by servlets and jsp pages. in chapter 3, well take a closer look at how jsp pages are actually turned into servlets automatically.if youre already fami

56、liar with servlets, this is old news. you can safely skip the rest of this chapter. 2.2.1 advantages over other server-side technologiesin simple terms, a servlet is a piece of code that adds new functionality to a server (typically a web server), just like cgi and proprietary server extensions such

57、 as nsapi and isapi. but compared to other technologies, servlets have a number of advantages:platform and vendor independenceall the major web servers and application servers support servlets, so a servlet-based solution doesnt tie you to one specific vendor. also, servlets are written in the java programming language, so they can be used on any operating system with a java runtime environment.integrationservlets are developed in java and can therefore take advantage of all other java technologies, such a

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論