The Common Gateway Interface (CGI) is an essential technology for the development of interactive Web pages. This rapidly growing field is one of the hottest areas of Internet development, and the Tool Command Language (Tcl) is ideally suited for all aspects of CGI development. Although Perl is currently the most popular language for CGI development, Tcl is an ideal development environment. Tcl's rich set of string manipulation commands and well-defined syntax greatly facilitate the dynamic creation of HTML documents, a key aspect of CGI programming. In addition to raw power, many extensions, such as Expect, make the Tcl environment ideal for complex scripting tasks, such as automating telnet or ftp sites from inside a Web page interface. CGI Programming with Tcl illustrates the many advantages Tcl holds for CGI programmers and demonstrates how to create powerful CGI applications. This book presents a series of increasingly sophisticated applications, beginning with a simple Hello World application and culminating in Web-based interfaces to back-end databases such as Oracle. Through these examples, you will learn Tcl programming essentials and valuable CGI programming techniques.Specific topics covered include: *A complete review of the CGI specification *How to build and process HTML forms *Debugging your CGI programs *Processing form data with CGI programs *Server Side Includes--allows you to embed commands inside your HTML files Accessing databases built entirely with Tcl *Image maps--creating clickable images for navigating links *Magic cookies and the privacy issues surrounding them *Using OraTcl to provide an interface to an Oracle database *Using the Tcl browser plug-in to run code inside your browser *Using Tcl's socket support for building a Web-based client/server chat room An experienced programmer unfamiliar with Tcl can learn the language by reading this must-have reference. Tcl's straightforward syntax and similarity to C make it possible for any programmer to work through the examples. Furthermore, Appendix C provides a Tcl reference. The accompanying CD-ROM contains complete source code for all the examples in the book, as well as a CGI library that makes it easy to generate CGI programs that dynamically produce HTML Web pages. 0201606291B04062001
Le informazioni nella sezione "Riassunto" possono far riferimento a edizioni diverse di questo titolo.
Why Learn CGI
In the fast-paced information age that we live in, it is almost a necessity to be well versed in the use of the World Wide Web. For many researchers, engineers, scientists, school teachers, and a host of other professionals it is a day-to-day part of our lives.
As companies embrace this technology, it is becoming more common for them to have one or more public Web sites on the Internet, as well as a host of internal Web sites that are available only to employees on a local intranet. Motorola, the company I work for, has many such public and private Web sites. Public Web sites portray a desired image of the company to the outside world; private Web sites allow for internal communication on a level that has never been achieved prior to the invention of the World Wide Web.
As the need for both public and private Web sites increases, so does the need for qualified programmers who can create and maintain them. Many people can write simple HTML files, but the numbers of people who can write and maintain the code that provides the dynamic content to these pages are in short supply.
The code that provides the dynamic content in most Web sites today is known as Common Gateway Interface (CGI) programming. CGI is a programming specification that defines a standard way for a Web server to communicate with a gateway program, typically just called a CGI program. Because Web servers are not designed to access databases, control hardware, or a host of other tasks that are available on most common Web sites today, they rely on these external CGI programs to do this work for them.
As an example, when you connect to a site on the Internet and request some information about your favorite sports team, the Web server passes the request over to a CGI program that interrogates an on-line database. This CGI program will retrieve the information you requested from the database, dynamically build an HTML page containing the results, and return it to your Web browser. In this manner the CGI program acts as a gateway to external resources, like a database or maybe even a camera mounted on the freeway providing traffic information.
A common misconception about CGI programs is that they must be written in Perl. Although Perl is perhaps the most common language for writing CGI programs, at least today, any number of other languages can be used. A CGI program is, after all, just a program and as such can be written in C, C++, Visual Basic, Tcl, Perl, or a host of other languages. Of all these languages, I believe Tcl to be the best match for the job. CGI programs by nature spend a lot of time manipulating text-based HTML documents and files. Tcl's rich set of string manipulation commands makes this type of work a breeze. Why I Wrote This Book
It's not that I wasn't busy enough in my current job! As a section manager for a software test team in the Motorola Computer Group, I was looking for ways to be more productive. I liked what I saw with the Tcl/Tk environment. As a hard-core C programmer, I was skeptical about using a scripting language for any type of mission-critical application. I was delightfully surprised with Tcl and became hooked on the language almost immediately. From the moment I executed my first command from the Tcl shell to the first-time execution of a Tcl script without the need for compiling, I started to feel a passion that had long been lost to the day-to-day grind of cranking out code. My enthusiasm became contagious and the number of Tcl users in my area continues to grow.
Because much of Tcl's syntax resembles C, it was possible to slide right into developing reasonably complex applications without feeling all the pain associated with learning a new language. Tcl's feature set is powerful enough to make implementation of reasonably complex algorithms enjoyable!
Our group initially embraced Tcl for its Expect extension. Expect is a powerful tool for dealing with interactive processes that fit the bill perfectly for building a complete, automated regression test environment. This same tool set is in use today validating firmware written for nearly all of the embedded computer products manufactured at the Motorola Computer Group in Tempe, Arizona. The development effort was not only shorter but much more enjoyable than it would have been in other languages I have worked with.
As the test effort expanded, we decided to begin publishing our results on our intranet. I agonized over the prospect of having to support yet another language, such as Perl, to write the CGI code, so I decided to try Tcl. I started with a few routines I had seen in Brent Welch's book Practical Programming in Tcl and Tk and was impressed at how easy it was to get interactive Web pages up and running. My library grew quickly and now contains nearly all the procedures required to make CGI programming fun!
Until recently, the majority of CGI programming has been targeted at application development for the Internet, meaning external to the company that developed it. Due to security considerations, these applications are placed in the hands of a very small number of programmers, or Web masters, as they are commonly referred to. An entire company's Web site may be handled by one or two people in this scenario.
As the need to disseminate information grows inside many companies, more and more businesses are looking at the intranet for solutions to their specialized communication needs. Intranets are generally protected networks, isolated from the outside world, used for a company's internal communications. Being more secure, it is becoming customary to let a larger number of CGI developers build applications for intranets. The skill sets of these individuals do not need to be as high as the traditional Web master because they are more isolated from the security risks associated with publishing on the Internet. Therefore, the numbers of individuals available to do this type of work is growing at a rapid rate.
I believe intranet development is exploding across the country, which is why I decided to write this book. As companies learn the advantages of publishing to an internal network, the need for CGI developers will grow exponentially as every group in a given company will begin to develop applications specific to their immediate needs. These may include internal access to localized databases, project-based FAQ lists, or remote control and status monitoring of development hardware or manufacturing systems. The possibilities are limitless! I feel that Tcl is the perfect language for this environment.
Because most of my CGI development for Motorola has been in an engineering environment, I have had to solve some problems outside the realm of traditional CGI programming. Some of these projects have included
Allowing password-protected Web access to our internal source code repository. Web control of power control modules and X10-based switching modules for remote access to lab hardware. Web-based data analysis tools for analyzing the results of our automated regression test suites. These test suites validate the firmware shipped with our embedded computer products. The whole automated environment was also written in Tcl and Expect. Web interfaces to custom-built and off-the-shelf databases like Oracle. (You don't have to look far inside any company to find a practical use for a good database.) Who Should Read This Book
This book is aimed at programmers and technical professionals interested in writing interactive applications for the World Wide Web using the Tcl language. These individuals may include, but are not limited to, application programmers, research assistants, test engineers, system administrators, or Web masters who are not yet familiar with Tcl.
There are large numbers of people who are already using Tcl who may not be aware of its capabilities as a CGI programming language, for example test engineers who are already using the Expect extension to Tcl. These individuals are frequently requested to make their test data available on their local intranet. Learning how to write CGI programs with Tcl allows these individuals to obtain all the benefits of publishing to their internal intranet without having to learn a new language.
C programmers will also love this environment for the logical syntax and its similarity to other procedural programming environments. What You Should Know to Read This Book
Because this book is about writing programs that use the Common Gateway Interface (CGI), it assumes the reader is an experienced programmer. Most chapters in this book also assume that the reader is already familiar with Tcl, though this is not a prerequisite. The book has been laid out in such a manner that the material progresses in a steady fashion from simple examples to complex applications.
Experienced programmers not familiar with Tcl should be able to learn Tcl as they read this book. Tcl's delightfully straightforward syntax makes this possible. While reading this book without prior Tcl coding experience would prove quite challenging to an individual who has never programmed before, it should not be difficult for an experienced C or C++ programmer to sit down and work through the examples. Appendix B provides a sufficient reference to learn Tcl as you read the book.
Another important prerequisite is a strong knowledge of HTML. Because a major requirement of most CGI programs is to dynamically produce HTML documents, it is imperative that the CGI programmer be well versed in HTML. An HTML reference is provided Appendix A, but you should seek out a tutorial-style book on HTML if you have never used the language before. What's in This Book
Rather than just illustrating tidbits of CGI programming, this book contains complete Web-based applications. The examples range from a simple Hello World application to interfacing with an Oracle database and a chat room that uses the Tcl Web browser plug-in and Tcl's excellent support for network socket programming. I felt that complete applications were the easiest way to master the principles of CGI programming, so I have done my best to encapsulate all the principles necessary to become a successful CGI programmer inside fully explained, completely functional Web-based programs. The enclosed CD contains the code for all the examples in this book and even provides a point-and-click Web page interface to all the examples. To run the examples in this fashion you will need to have access to a Web server and install the contents of the CD into an executable directory on that Web server. A short synopsis of each chapter's contents follows.
Chapter 1, The Internet, provides the necessary background information required to understand the rest of the chapters in this book. CGI programming is just one aspect of a single service available on the Internet. It is important for the reader to understand where CGI fits in, as well as some of the terminology associated with it and the Internet in general.
Chapter 2, The Common Gateway Interface, introduces the reader to CGI and explains the rules by which a CGI program operates. An in-depth discussion of HTTP (HyperText Transfer Protocol) is also provided. HTTP is the underlying method of communication between a Web browser and a Web server.
Chapter 3, Getting Started, will guide you through the installation of the cgi.tcl library contained on the enclosed CD. It will also show you how to install all the example code so you can run the enclosed examples on your own Web browser.
Chapter 4, Hello World, provides the prerequisite Hello World program that is the cornerstone of every comprehensive programming book. This chapter contrasts the difference between a static Web page version and the CGI programming equivalent for producing "Hello World" on the client's Web browser.
Chapter 5, A Web-Based Directory Browser, develops a useful tool for browsing source files on the Web server. The "File Viewer" uses information available from the Web server to restrict access to a user-defined list of IP addresses without relying on the operating system. This file viewer can be used to browse the source code contained on the enclosed CD, once the examples are made available through your own Web server.
Chapter 6, The Mortgage Calculator, is a Web-based mortgage calculator that can be used to calculate monthly payments on a home loan or a complete amortization schedule. Key concepts in this chapter include the use of HTML form fields, how the CGI program extracts the form data from the Web server, validation of the form data, and dynamic generation of the resulting display.
Chapter 7, Counting Your Hits, shows you how to add a page hit counter to the mortgage calculator example of Chapter 6. This chapter deals with using a file in the local file system to maintain state information between invocations of the CGI program.
Chapter 8, Server Side Includes, demonstrates a useful feature available inside most Web server applications that allows for dynamic substitution of directives that can be embedded inside your HTML documents. Server Side Includes are not considered CGI programming by themselves but can be used effectively to augment your CGI applications, possibly reducing the amount of code you need to generate to get your job done.
Chapter 9, Image Maps, describes how to build clickable images on the client's Web browser. These types of images allow users to navigate using graphical links rather than textual ones. A simple conference room example shows how to display a building floor plan and return information about a selected conference room when the user clicks on it.
Chapter 10, Putting Data Behind Your Forms, deals with one of the fastest-growing aspects of the World Wide Web today -- accessing databases. The first example uses a simple text file to contain a database of Super Bowl statistics for every Super Bowl played. The second introduces a database written entirely in Tcl to store statistics about various NFL players. The source code for the database, which was developed just for this book, is included on the enclosed CD.
Chapter 11, Cookies Anyone?, explains what magic cookies are and why they are important to the CGI programmer. A cookie viewer is built that can create and destroy cookies on your own Web browser. Also provided is a discussion of the controversy surrounding cookies as it relates to privacy issues.
Chapter 12, The Bug Tracker, builds on the information supplied in Chapters 10 and 11 with an interactive database application. The application allows for password-protected, read-write access to the Tcl database described in Chapter 10. A bug tracking program is developed to track problems during new product development. The code can easily be adapted to any type of problem reporting system.
Chapter 13, Building Gateways to Your Data, uses an off-the-shelf package named OraTcl to provide an interface to an Oracle database. The example application builds a small database containing information about a few hard drive manufacturers. The database includes specifications on some of the specific hard drives built by these manufacturers. This chapter highlights the advantages of using a pow...About the Author:
David Maggiano has worked with Motorola for more than sixteen years. He has used Tcl and Expect to build complex regression test suites that are used to test the embedded firmware shipped with most of the Motorola Computer Group's systems controller boards. In addition, for Web application development, including interfaces to back-end databases, he uses Tcl exclusively. 0201606291AB04062001
Le informazioni nella sezione "Su questo libro" possono far riferimento a edizioni diverse di questo titolo.
Descrizione libro Addison-Wesley Pub (Sd), 1999. Paperback. Condizione libro: New. Codice libro della libreria DADAX0201606291
Descrizione libro Addison-Wesley Pub (Sd), 1999. Paperback. Condizione libro: New. Never used!. Codice libro della libreria P110201606291
Descrizione libro Addison-Wesley Pub (Sd). PAPERBACK. Condizione libro: New. 0201606291 New Condition. Codice libro della libreria NEW6.3033985
Descrizione libro Addison-Wesley Pub (Sd), 1999. Paperback. Condizione libro: New. book. Codice libro della libreria M0201606291