By itself, a Web page coded in HTML is simply a “static” display that does not interact with the user (other than for the selection of links). (See html, dhtml, and xhtm.) Many Web services, including online databases and e-commerce transactions, require that the user be able to interact with the server. For example, an online shopper may need to browse or search a catalog of CD titles, select one or more for purchase, and then complete the transaction by provid-ing credit card and other information. These functions are provided by “gateway programs” on the server that can access databases or other facilities.
One way to provide interaction with (and through) a Web page is to use the CGI (common gateway interface). CGI is a facility that allows Web browsers and other client programs to link to and run programs stored on a Web site. The stored programs, called scripts, can be written in various languages such as JavaScript or PHP (see scripting languages) and placed in a cgi-bin folder on the Web server.
The CGI script is referenced by an HTML hyperlink on the Web page, such as
<A HREF=“http://www.MyServer.com/cgi-bin/ MyScript”>MyScript </A>
Or more commonly, it is included in an HTML form that the user fills in, then clicks the Submit button. In either case, the script executes. The script can then pro-cess the information the user provided on the form, and return information to the user’s Web browser in the form of an HTML document. The script can perform additional functions such as logging the user’s query for marketing purposes.
The complexity of Web features and the heavy load on servers have prompted a number of strategies for serving dynamic content more efficiently. Traditionally, each time a CGI request is passed to the URL for a script, the appro-priate language interpreter must be loaded and initialized. However, modern Web servers such as Apache have built-in modules for commonly used scripting languages such as PHP, Perl, Python, and Ruby. This allows the Web server to run the script directly without the overhead of starting a new interpreter process.
A more fundamental shift in implementation is the development of methods to tie together DHTML and XML with a document model and scripting languages to allow for dynamic changes in page content without having to reload the page (see Ajax).
Note: the acronym CGI can also stand for “computer-generated imagery” (see computer graphics).
No comments:
Post a Comment