动态Web文档 毕业论文外文文献翻译.doc
《动态Web文档 毕业论文外文文献翻译.doc》由会员分享,可在线阅读,更多相关《动态Web文档 毕业论文外文文献翻译.doc(17页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、外文翻译Dynamic Web DocumentsSo far, the model we have used is that of Fig. 6-6: the client sends a file name to the server, which then returns the file. In the early days of the Web, all content was, in fact, static like this (just files). However, in recent years, more and more content has become dyna
2、mic, that is, generated on demand, rather than stored on disk. Content generation can take place either on the server side or on the client side. Let us now examine each of these cases in turn.Server-Side Dynamic Web Page GenerationTo see why server-side content generation is needed, consider the us
3、e of forms, as described earlier. When a user fills in a form and clicks on the submit button, a message is sent to the server indicating that it contains the contents of a form, along with the fields the user filled in. This message is not the name of a file to return. What is needed is that the me
4、ssage is given to a program or script to process. Usually, the processing involves using the user-supplied information to look up a record in a database on the servers disk and generate a custom HTML page to send back to the client. For example, in an e-commerce application, after the user clicks on
5、 PROCEED TO CHECKOUT, the browser returns the cookie containing the contents of the shopping cart, but some program or script on the server has to be invoked to process the cookie and generate an HTML page in response. The HTML page might display a form containing the list of items in the cart and t
6、he users last-known shipping address along with a request to verify the information and to specify the method of payment. The steps required to process the information from an HTML form are illustrated in Fig. 7-33.Figure 7-33. Steps in processing the information from an HTML form.The traditional wa
7、y to handle forms and other interactive Web pages is a system called the CGI (Common Gateway Interface). It is a standardized interface to allow Web servers to talk to back-end programs and scripts that can accept input (e.g., from forms) and generate HTML pages in response. Usually, these back-ends
8、 are scripts written in the Perl scripting language because Perl scripts are easier and faster to write than programs (at least, if you know how to program in Perl). By convention, they live in a directory called cgi-bin, which is visible in the URL. Sometimes another scripting language, Python, is
9、used instead of Perl.As an example of how CGI often works, consider the case of a product from the Truly Great Products Company that comes without a warranty registration card. Instead, the customer is told to go to to register on-line. On that page, there is a hyperlink that says:Click here to regi
10、ster your product This link points to a Perl script, say, When this script is invoked with no parameters, it sends back an HTML page containing the registration form. When the user fills in the form and clicks on submit, a message is sent back to this script containing the values filled in using the
11、 style of Fig. 7-30. The Perl script then parses the parameters, makes an entry in the database for the new customer, and sends back an HTML page providing a registration number and a telephone number for the help desk. This is not the only way to handle forms, but it is a common way. There are many
12、 books about making CGI scripts and programming in Perl. A few examples are (Hanegan, 2001; Lash, 2002; and Meltzer and Michalski, 2001).CGI scripts are not the only way to generate dynamic content on the server side. Another common way is to embed little scripts inside HTML pages and have them be e
13、xecuted by the server itself to generate the page. A popular language for writing these scripts is PHP (PHP: Hypertext Preprocessor). To use it, the server has to understand PHP (just as a browser has to understand XML to interpret Web pages written in XML). Usually, servers expect Web pages contain
14、ing PHP to have file extension php rather than html or htm.A tiny PHP script is illustrated in Fig. 7-34; it should work with any server that has PHP installed. It contains normal HTML, except for the PHP script inside the tag. What it does is generate a Web page telling what it knows about the brow
15、ser invoking it. Browsers normally send over some information along with their request (and any applicable cookies) and this information is put in the variable HTTP_USER_AGENT. When this listing is put in a file test.php in the WWW directory at the ABCD company, then typing the URL will produce a We
16、b page telling the user what browser, language, and operating system he is using.Figure 7-34. A sample HTML page with embedded PHP.PHP is especially good at handling forms and is simpler than using a CGI script. As an example of how it works with forms, consider the example of Fig. 7-35(a). This fig
17、ure contains a normal HTML page with a form in it. The only unusual thing about it is the first line, which specifies that the file action.php is to be invoked to handle the parameters after the user has filled in and submitted the form. The page displays two text boxes, one with a request for a nam
18、e and one with a request for an age. After the two boxes have been filled in and the form submitted, the server parses the Fig. 7-30-type string sent back, putting the name in the name variable and the age in the age variable. It then starts to process the action.php file, shown in Fig. 7-35(b) as a
19、 reply. During the processing of this file, the PHP commands are executed. If the user filled in Barbara and 24 in the boxes, the HTML file sent back will be the one given in Fig. 7-35(c). Thus, handling forms becomes extremely simple using PHP.Figure 7-35. (a) A Web page containing a form. (b) A PH
20、P script for handling the output of the form. (c) Output from the PHP script when the inputs are Barbara and 24, respectively.Although PHP is easy to use, it is actually a powerful programming language oriented toward interfacing between the Web and a server database. It has variables, strings, arra
21、ys, and most of the control structures found in C, but much more powerful I/O than just printf. PHP is open source code and freely available. It was designed specifically to work well with Apache, which is also open source and is the worlds most widely used Web server. For more information about PHP
22、, see (Valade, 2002).We have now seen two different ways to generate dynamic HTML pages: CGI scripts and embedded PHP. There is also a third technique, called JSP (JavaServer Pages), which is similar to PHP, except that the dynamic part is written in the Java programming language instead of in PHP.
23、Pages using this technique have the file extension jsp. A fourth technique, ASP (Active Server Pages), is Microsofts version of PHP and JavaServer Pages. It uses Microsofts proprietary scripting language, Visual Basic Script, for generating the dynamic content. Pages using this technique have extens
24、ion asp. The choice among PHP, JSP, and ASP usually has more to do with politics (open source vs. Sun vs. Microsoft) than with technology, since the three languages are roughly comparable.The collection of technologies for generating content on the fly is sometimes called dynamic HTML.Client-Side Dy
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 动态Web文档 毕业论文外文文献翻译 动态 Web 文档 毕业论文 外文 文献 翻译
限制150内