高校学生公寓管理系统_外文翻译(范文)内容摘要:

er the plete page. Request Parameters Besides the URI and headers, a request message can contain additional information in the form of parameters. If the URI identifies a serverside 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 emerce application, the URI may identify a program that processes orders, with the user39。 s 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 starts with a question mark (?) and consists of name/value pairs separated by ampersands (amp。 ). These names and values must be URLencoded, meaning that special characters, such as whitespace, question marks, ampersands, and all other nonalphanumeric characters are encoded so that they don39。 t get confused 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 parameters are sent as part of the request body, they follow the same syntax。 URL encoded name/value pairs separated by ampersands. Request Methods As described earlier, GET is the most monly used request method, intended to retrieve a resource without causing anything else to happen on the server. The POST method is almost as mon 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 always 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 a element, clicking on the link results in a GET request 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: a href=/forecast?city=Hermosa+Beachamp。 state=CA Hermosa Beach weather forecast /a When you use a form to send user input to the server, you can specify whether to use the GET or POST method with the method attribute, as shown here: form action=/forecast method=POST City: input name=city type=text State: input name=state type=text p input type=SUBMIT /form 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/ Host: UserAgent: Mozilla/ (Windows。 U。 Win 9x。 enUS。 rv: ) Accept: image/gif, image/jpeg, image/pjpeg, image/png, */* Acceptlanguage: enUS Acceptcharset: iso88591,*,utf8 city=Hermosa+Beachamp。 state=CA Due 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 different 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 request, on the other hand, can39。 t 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 it39。 s okay to send the request again Besides the GET and POST methods, HTTP specifies the following methods: OPTIONS The OPTIONS method is used to find out what options (., methods) a server or a resource offers. HEAD The HEAD method is used to get a response with all headers generated by a GET request but without the body. It can make sure a link is valid or to see when a resource was last modified. PUT The PUT method is used to store the message body content on the server as a resource identified by the URI. DELETE The DELETE method is used to delete the resource identified by the URI. TRACE The TRACE method is used for testing the munication 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 aren39。 t normally used in a web application. Servlets The JSP specification is based on the Java servlet specification. In fact, JSP pages are often bined 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, we39。 ll take a closer look at how JSP pages are actually turned into servlets automatically. If you39。 re already familiar with servlets, this is old news. You can safely skip the rest of this chapter. Advantages over Other ServerSide Technologies In 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 as NSAPI and ISAPI. But pared to other technologies, servlets have a number of advantages: Platform and vendor independence All the major web servers and application servers support servlets, so a servletbased solution doesn39。 t 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。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。