CGI Programming on the World Wide WebBy Shishir Gundavaram
1st Edition March 1996
This book is out of print, but it has been made available online through the O'Reilly Open Books Project.
The Common Gateway Interface (CGI) emerged as the first way to present dynamically generated information on the World Wide Web. CGI allows the computer to generate Web pages instantly at the user's request rather than being written by someone in advance. And at the time of this writing, it remains the only stable and well-understood method for creating such pages. Java presents problems that have not yet been solved. Other products are currently just in the announcement stage.
CGI is fun. You can get a kick out of writing scripts that perform tricks for you, and the users enjoy the spice the scripts add to your Web pages. But CGI has a serious side too: It lets the Internet offer the kind of interactive, user-driven applications that modern computer users have come to expect. CGI opens up an entire class of modern applications to the Web.
Today's computer users expect custom answers to particular questions. Gone are the days when people were satisfied by the computing center staff passing out a single, general report to all users. Instead, each salesperson, manager, and engineer wants to enter specific queries and get up-to-date responses. And if a single computer can do that, why not the Web?
This is the promise of CGI. You can display sales figures for particular products month by month, as requested by your staff, using beautiful pie charts or plots. You can let customers enter keywords in order to find information on your products. You can also offer day-to-day conveniences, like collecting comments from users, offering them searches through your archives, and letting them sign your guestbook.
So, on to the book. What will you encounter here? A variety of powerful applications that you can use and that will serve as models for your own CGI scripts. Among the complete applications in the book are an animated clock, a search tool, a survey, a quiz program, a game, a gateway to Usenet News, and an appointment calendar based on a clickable imagemap.
If you want to set up your own database and can't afford a commercial product like Oracle, you can use the Sprite extension to Perl that I wrote. Sprite offers a subset of SQL commands with a flat file as the database. I also offer a debugging program called CGI Lint, and a program that lets you write and parse extensions to HTML. I wrote the latter program to support my quiz application, but you can adapt it to other purposes without much trouble. Appendix E, Applications, Modules, Utilities, and Documentation, lists where you can get Sprite and CGI Lint.
But the most important tool I hope to give you is not any particular program, but a thorough understanding of CGI's potential and how to invoke it. The ideas in these programs should become yours for any purpose you want, no matter what operating system or language you use. The old adage about "teaching someone how to fish" may no longer be politically correct, in a world of dangerously depleted fish stocks, but the metaphor describes what I want to do. The techniques I show in this book are fundamental CGI practices: passing information between client (browser) and server, interacting with databases through SQL, generating graphics, writing gateways to existing programs, and storing information while handling multiple forms.
Back to: CGI Programming on the World Wide Web
© 2001, O'Reilly & Associates, Inc.