`
`A NUTSHELL®
`
`HANDBOOK
`
`Sbisbir Gurzdavaram
`
`O’Reilly & Associates, Inc.
`
`Petitioner Microsoft Corporation - Ex. 1039, p. Cover
`
`
`
`
`
`
`
`
`
`Petitioner 1\/Iicrosoft Corporation - Ex. 1039, p. i
`
`Petitioner Microsoft Corporation - Ex. 1039, p. i
`
`
`
`CGI Programming
`on the World Wide Web
`
`Petitioner Microsoft Corporation - Ex. 1039, p. ii
`
`
`
`CGI Programming
`on the World Wide Web
`
`Shishir Gundavaram
`
`O’Reilly & Associates, Inc.
`Bonn ¯ Cambridge ¯ Paris ¯ Sebastopol ¯ Tokyo
`
`Petitioner Microsoft Corporation - Ex. 1039, p. iii
`
`
`
`CGI Programming on the World Wide Web
`by Shishir Gundavaram
`
`Copyright © 1996 O’Reilly & Associates, Inc. All rights reserved.
`Printed in the United States of America.
`
`Published by O’Reilly & Associates, Inc., 103 Morris Street, Suite A, Sebastopol, CA 95472.
`
`Editors: Andy Oram and Linda Mui
`
`Production Editor: Jane Ellin
`
`Printing History:
`
`March 1996:
`
`First Edition
`
`Nutshell Handbook and the Nutshell Handbook logo are registered trademarks of O’Reilly &
`Associates, Inc.
`
`Many of the designations used by manufacturers and sellers to distinguish their products are
`claimed as trademarks. Where those designations appear in this book, and O’Reilly &
`Associates, Inc. was aware of a trademark claim, the designations have been printed in caps
`or initial caps.
`
`While every precaution has been taken in the preparation of this book, the publisher assumes
`no responsibility for errors or omissions, or for damages resulting from the use of the
`information contained herein.
`
`This book is printed on acid-free paper with 85% recycled content, 15% post-consumer waste.
`O’Reilly & Associates is committed to using paper with the highest recycled content available
`consistent with high quality.
`
`ISBN: 1-56592-168-2
`
`[4/96]
`
`Petitioner Microsoft Corporation - Ex. 1039, p. iv
`
`
`
`Table of Contents
`
`Preface ................................................................................................. ix
`
`1: The Common Gateway Interface (CGI) .................................... 1
`What Is CGI? ......................................................................................................... 1
`CGI Applications ............................................................. £ .................................... 2
`Some Working CGI Applications ........................................................................ 5
`Internal Workings of CGI ...................... .............................................................. 6
`Configuring the Server ......................................................................................... 8
`Programming in CGI ............................................................................................ 9
`CGI Considerations ............................................................................................ 13
`Overview of the Book ....................................................................................... 13
`
`2: Input to the Common Gateway Interface ............................... 15
`Introduction ........................................................................................................ 15
`Using Environment Variables ............................................................................ 16
`Accessing Form Input ........................................................................................ 23
`Extra Path Information ....................................................................................... 30
`Other Languages Under UNIX .......................................................................... 31
`Other Languages Under Microsoft Windows .................................................... 35
`Other Languages on Macintosh Servers ............................................................ 36
`Examining Environment Variables .................................................................... 37
`
`V
`
`Petitioner Microsoft Corporation - Ex. 1039, p. v
`
`
`
`vi
`
`3"
`
`Table of Contents
`
`Output from the Common Gateway Interface ......... : ............ 39
`Overview ............................................................................................................ 39
`CGI and Response Headers ............................................................................... 40
`Accept Types and Content Types ..................................................................... 41
`The Content-length Header ............................................................................... 42
`Server Redirection .............................................................................................. 44
`The "Expires" and "Pragma" Headers ............................................................... 46
`Status Codes ....................................................................................................... 47
`Complete (Non-Parsed) Headers .......................................... i ........................... 49
`
`4."
`
`Forms and CGL ................................................................................ 51
`HTML Tags ......................................................................................................... 52
`Sending Data to the Server ................................................................................ 59
`Designing Applications Using Forms in Perl .................................................... 63
`Decoding Forms in Other Languages ............................................................... 69
`
`5."
`
`Server Side Includes ....................................................................... 87
`Introduction ........................................................................................................ 87
`Configuration ...................................................................................................... 89
`Environment Variables ....................................................................................... 90
`Including Boilerplates ........................................................................................ 91
`File Statistics ....................................................................................................... 92
`Executing External Programs ............................................................................. 93
`Executing CGI Programs .................................................................................... 94
`Tailoring SSI Output ....................... ................................................................... 99
`Common Errors ................................................................................................ 100
`
`6:
`
`Hypermedia Documents ............................................................ 101
`Creating Dynamic Home Pages ....................................................................... 101
`CGI Examples with PostScript ......................................................................... 104
`The gd Graphics Library .................................................................................. 116
`CGI Examples with gnuplot ............................................................................ 127
`CGI Examples with pgperl .............................................................................. 131
`Animation ......................................................................................................... 136
`
`Petitioner Microsoft Corporation - Ex. 1039, p. vi
`
`
`
`Table of Contents
`
`vii
`
`7: Advanced Form Applications ................... ................................ 143
`Guestbook ................................ ~ ....................................................................... 143
`Survey/Poll and Pie Graphs ............................................................................ 151
`Quiz/Test Form Application ............................................................................ 163
`
`Security ............................................................................................................. 180
`
`8." Multiple Form Interaction ........................................................ 183
`Hidden Fields ................................................................................................... 184
`
`CGI Side Includes ............................................................................................ 190
`
`Netscape Persistent Cookies ............................................................................ 202
`
`9." Gateways, Databases, and Search/Index Utilities ............ 205
`UNIX Manual Page Gateway ........................................................................... 205
`Mail Gateway .................................................................................................... 215
`
`Relational Databases ........................................................................................ 223
`Search/Index Gateway ..................................................................................... 255
`
`10: Gateways to Internet Information Servers .......................... 263
`Overview .......................................................................................................... 263
`What Are Sockets? ............................................................................................ 264
`
`Socket I/O in Perl ............................................................................................ 264
`
`Socket Library ................................................................................................... 268
`
`Checking Hypertext (HTTP) Links .................................................................. 269
`
`Archie ................................................................................................................ 271
`
`Network News on the Web ............................................................................. 279
`Magic Cookies .................................................................................................. 290
`Maintaining State with a Server ....................................................................... 293
`Forking/Spawning Child Processes ................................................................. 308
`
`11." Advanced and Creative CGI Applications ...................... , .... 311
`Animated Clock ................................................................................................ 311
`
`Game of Concentration .................................................................................... 314
`
`Introduction to Imagemaps ............................................................................. 326
`Calendar Manager ............................................................................................ 327
`
`12: Debugging and Testing CGIApplications, ........................... 367
`Common Errors ...................... : ......................................................................... 367
`Programming/System Errors ............................................................................ 370
`
`Petitioner Microsoft Corporation - Ex. 1039, p. vii
`
`
`
`viii
`
`Table of Contents
`
`Environment Variables ..................................................................................... 372
`Logging and Simulation ................................................................................... 373
`CGI Lint--A Debugging/Testing Tool ............................................................ 375
`Set UID/GID Wrapper ..................................................................................... 380
`
`A: Perl CGI Programming FAQ ..................................................... 383
`
`B." Summary of Regular Expressions .......................................... 401
`
`C." CGI Modules for Perl 5 ............................................................... 405
`
`D: CGI Lite ............................................................................................ 413
`
`E." Applications, Modules, Utilities, and Documentation ..... 417
`
`Index ................................................................................................ 423
`
`Petitioner Microsoft Corporation - Ex. 1039, p. viii
`
`
`
`;i[
`
`i:iI¸/¸ r
`
`Preface
`
`The Common Gateway Interface (CGI) emerged as the first way to present dynam-
`ically 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 appli-
`cations 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 engi-
`neer 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 prod-
`ucts. 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.
`
`ix
`
`Petitioner Microsoft Corporation - Ex. 1039, p. ix
`
`
`
`x
`
`PreFace
`
`What’s in the Book
`
`So, on to the book. What will you encounter here? A variety of powerful applica-
`tions 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 fiat 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 tech-
`niques 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 informa-
`tion while handling multiple forms.
`
`What You Are Expected to Know
`Before Reading
`
`People at many different levels of computer expertise come to CGI to solve their
`problems. CGI involves programming, so I expect you to be comfortable thinking
`like a programmer. I don’t expect you to know any particular language, but you
`must promise that when I show you a loop, you won’t be thrown for a loop. I
`want this book to be chock full of unique CGI techniques that you won’t find else-
`where, and therefore I don’t want to take up space telling you things that you can
`find in many other books.
`
`The language of choice for CGI programming is Perl, at least on UNIX systems. I
`also talk a little about several other languages, notably Tcl. But most examples are
`in Perl. Still, I don’t expect to force you into being a Perl programmer. I tiT to
`describe everything I do carefully in plain English, so you can implement the
`
`Petitioner Microsoft Corporation - Ex. 1039, p. x
`
`
`
`Preface
`
`xi
`
`same techniques in the language of your choice. Remember, the main thing to
`learn is the concept; the way you implement it is up to you.
`
`If you do come to the same conclusion that thousands of CGI programmers have
`reached that Perl is the easiest language in which to do the text and array manip-
`ulation that characterizes CGI tasks--then you can use my examples as a basis for
`your own Perl programs, and supplement the book with either the extensive
`manual pages or the books on Perl from O’Reilly & Associates: Learning Perl by
`Randal Schwartz as a beginning tutorial and Programming Perl by Larry Wall and
`Randal Schwartz for advanced techniques. Perl is available on many non-UNiX
`systems, by the way.
`
`I should admit up front that there’s a UNIX bias in this book, because UNIX is the
`most popular system for Web servers. Some of the things I do all the time on
`UNIX--such as pipe output to another program--have to be done differently on
`other systems. And similarly, some of the security concerns that go along with
`executing UNIX commands won’t exist on other systems. But I repeat: The basic
`CGI tasks are the same in any language, on any system. They spring from the divi-
`sion of labor between client and server, and the protocols they use to
`communicate.
`
`Organization of This Book
`
`CGI concepts are not very difficult, but you have to firmly understand a few
`aspects of how the client and server work before you start programming. So I
`offer a quick introduction in Chapter 1, followed by a discussion of basic proto-
`cols in Chapters 2 and 3. After that, it’s off on a whirlwind tour of CGI techniques,
`with complete working examples.
`
`Chapter 1, The Common Gateway Interface (CGI), explains how CGI works and
`compares the different languages you can use to write scripts.
`
`Chapter 2, Input to the Common Gateway Interface, describes the input from Web
`client to server, which you need to capture and parse. Query strings and input
`streams are discussed here.
`
`Chapter 3, Output from the Common Gateway Interface, describes the output that
`a Web server sends to a client. Everything a CGI programmer needs to know
`about the HTTP protocol is here, including error values and HTTP headers.
`
`Chapter 4, Forms and CGI, introduces you to HTML forms and to some simple
`form-based CGI applications.
`
`Chapter 5, Server Side Includes, covers some useful, quick services that the server
`can handle for you, such as inserting the current date into your document.
`
`Petitioner Microsoft Corporation - Ex. 1039, p. xi
`
`
`
`~ W~
`
`xii
`
`Preface
`
`Chapter 6, Hypermedia Documents, shows a variety of ways to incorporate
`graphics and animation into CGI output. Among the languages and extensions
`illustrated are PostScript, gnuplot, the gd extension to Perl, and the pgperl plotting
`library.
`
`Chapter 7, Advanced Form Applications, shows more complicated examples using
`the forms interface to CGI. I show a generalized interface that you can use to let
`your colleagues develop their own forms (the quiz application I mentioned
`earlier).
`
`Chapter 8, Multiple Form Interaction, shows several approaches to passing infor-
`mation between multiple CGI programs. I show how to use hidden fields,
`Netscape’s persistent cookies, and CGI side includes to "maintain state."
`
`Chapter 9, Gateways, Databases, and Search/Index Utilities, shows you how to
`hook up with existing programs to extend the power of your own CGI script. I
`introduce several ways to use SQL in a CGI program, including interfaces to
`Oracle, Sybase, and my own Sprite library.
`
`Chapter 10, Gateways to Internet Information Servers, extends the ideas in Chap-
`ters 7 through 9 to communication over the Intemet. The main example in this
`chapter is a cookie server that can maintain state information for multiple CGI
`programs.
`
`Chapter 11, Advanced and Creative CGI Applications, includes several advanced
`examples, particularly a calendar program that shows you how to generate an
`imagemap and interpret clicks on the fly.
`
`Chapter 12, Debugging and Testing CGI Applications, lists common errors and
`shows you how to use my CGI Lint tool.
`
`Appendix A, Perl CGI Programming FAQ, is a Frequently Asked Questions list for
`Perl CGI.
`
`Appendix B, Summary of Regular Expressions, lists syntax for regular expressions
`in Perl.
`
`Appendix C, CGI Modules for Perl 5, introduces a variety of CGI n-iodules for Perl
`5 and shows some examples of their use.
`
`Appendix D, CGILite, introduces the CGI Lite library of Per1 5.
`
`Appendix E, Applications, Modules, Utilities, and Documentation, lists URLs and
`print resources for CGI documentation and software.
`
`Petitioner Microsoft Corporation - Ex. 1039, p. xii
`
`
`
`Preface
`
`...
`Xlgl~
`
`Conventions in This Book
`Courier
`
`is used for HTTP headers, status codes, MIME content types,
`directives in configuration files, and computer output in text
`
`Italic
`
`is used for filenames, pathnames, newsgroup names, Internet
`addresses (URLs), email addresses, variable names (except in
`examples), terms being introduced, commands, options/switches,
`program names, subroutine names, functions, arrays, operators,
`methods, and hostnames
`
`ALL CAPS
`
`is used for environment variables, HTML attributes, and HTML tags
`(within angle brackets <>)
`
`Acknowledgments
`
`I remember early last year when there was so much demand for a CGI book, and
`yet there was not even one book to help all the eager users put up counters or
`guestbooks. My boss at that time, Dyung Le, suggested that we write a book on
`CGI. Of course, we laughed it off several minutes later.
`
`But, the idea never left either one of us. Several days later, we started writing up
`a contract, and the rest is history--thanks to Adrian Nye, an editor at O’Reilly,
`who helped us put the contract together. It was a dream come tale: writing a tech-
`nical book for O’Reilly & Associates.
`
`First and foremost, I’d like to thank Mr. Le for not only suggesting the idea for the
`book, but giving me an opportunity to develop software straight out of high
`school. In addition, I’d like to thank Rita Horsey, my other boss, who also taught
`me quite a bit, and provided me with an Internet connection in the early days of
`the book.
`
`Of course, I’d also like to thank my family for not only putting up with my bizarre
`work hours during the entire writing period, but also coming to my assistance
`whenever I needed it. There’s no way I could have finished this book without
`their support.
`
`Thanks to all the reviewers and everyone who provided suggestions: Jeffrey Fried1
`(the king of regular expressions), Andreas Koenig (the father of MakeMaker),
`Marc Hedlund (the originator of the CGI FAQ), Tom Christiansen (the UNIX
`wizard), Jon Backstrom, Joseph Radin, Paul DuBois, and from ORA, Norman
`Walsh, Paula Ferguson, Ellie Cutler, Tanya Herlick, Frank Wi!lison, Andy Oram,
`Linda Mui (more on these guys in a minute), and Tim O’Reilly (the godfather of
`the Nutshell).
`
`L
`
`ili
`
`Petitioner Microsoft Corporation - Ex. 1039, p. xiii
`
`
`
`xiv
`
`Preface
`
`I had the privilege of working with two really excellent teachers, Andy and Linda,
`whom I also consider my friends. They’ve guided me through the entire process,
`and their editorial criticisms were always right on. So I’d like to thank them for
`everything.
`
`Unfortunately, Andy has been through some very tough and trying times in the
`last several months after an auto accident. No doubt, he’ll be back to doing what
`he does best in no time! Get well soon, Andy. I also can’t believe the amount of
`time Linda has devoted to the book, despite going through the trials and tribula-
`tions of pregnancy. You guys are great!
`
`Of course, a great big thanks go out to the production staff at ORA, especially
`Jane Ellin, who has done a great job managing the production responsibilities,
`with help from Mike Sierra, Kismet McDonough, Mary Ann Faughnan, Sheryl
`Avruch, Sue Willing, Hanna Dyer, and Clairemarie Fisher O’Leary. Thanks to Chris
`Reilley for all the great figures, Edie Freedman for designing the cover (which I
`wasn’t happy with originally, but have come to love!), Seth Maislin for the index,
`and Nancy Priest for the internal design.
`
`And last, but not least, a thanks to all my friends here and to my family and rela-
`tives in India, especially my grandparents.
`
`Hope you find the book useful!
`
`Petitioner Microsoft Corporation - Ex. 1039, p. xiv
`
`
`
`The Common
`Gateway Interface
`(CGD
`
`f
`
`What Is CGI?
`
`As you traverse the vast frontier of the World Wide Web, you will come across
`documents that make you wonder, "How did they do this?" These documents
`could consist of, among other things, forms that ask for feedback or registration
`information, imagemaps that allow you to click on various parts of the image,
`counters that display the number of users that accessed the document, and utili-
`ties that allow you to search databases for particular information. In most cases,
`you’ll find that these effects were achieved using the Common Gateway Interface,
`commonly known as CGI.
`
`One of the Internet’s worst-kept secrets is that CGI is astoundingly simple. That is,
`it’s trivial in design, and anyone with an iota of programming experience can
`write rudimentary scripts that work. It’s only when your needs are more
`demanding that you have to master the more complex workings of the Web. In a
`way, CGI is easy the same way cooking is easy: anyone can toast a muffin or
`poach an egg. It’s only when you want a Hollandaise sauce that things start to get
`complicated.
`
`CGI is the part of the Web server that can communicate with other programs
`running on the server. With CGI, the Web server can call up a program, while
`passing use>specific data to the program (such as what host the user is
`connecting from, or input the user has supplied using HTML form syntax). The
`program then processes that data and the server passes the program’s response
`back to the Web browser.
`
`CGI isn’t magic; it’s just programming with some special types of input and a few
`strict rules on program output. Everything in between is just programming. Of
`
`i!
`
`Petitioner Microsoft Corporation - Ex. 1039, p. 1
`
`
`
`Chapter 1: The Common Gateway Interface (CGI)
`
`course, there are special techniques that are particular to CGI, and that’s what this
`book is mostly about. But underlying it all is the simple model shown in
`Figure 1-1.
`
`WWW Browser
`(on client)
`
`Server
`
`Application
`
`!i¸ il
`
`ili
`
`J~
`
`Call CGI
`
`,,
`
`CGI ........
`""--.
`............ Program’s ...................
`
`response
`
`0
`
`CGI ....
`Program’s ......
`response
`
`Figure 1-1. Simple diagram of CGI
`
`CGI Applications
`
`CGI turns the Web from a simple collection of static hypermedia documents into
`a whole new interactive medium, in which users can ask questions and run appli-
`cations. Let’s take a look at some of the possible applications that can be
`designed using CGI.
`
`Forms
`
`One of the most prominent uses of CGI is in processing forms. Forms are a subset
`of HTML that allow the user to supply information. The forms interface makes
`Web browsing an interactive process for the user and the provider. Figure 1-2
`shows a simple form.
`
`As can be seen from the figure, a number of graphical widgets are available for
`form creation, such as radio buttons, text fields, checkboxes, and selection lists.
`When the form is completed by the user, the Submit Order! button is used to
`send the information to the server, which executes the program associated With
`the particular form to "decode" the data.
`
`Generally, forms are used for two main purposes. At their simplest, forms can be
`used to collect information from the user. But they can also be used in a more
`complex manner to provide back-and-forth interaction. For example, the user can
`be presented with a form listing the various documents available on the server, as
`well as an option to search for particular information within these documents. A
`
`~!i~
`
`L
`
`Petitioner Microsoft Corporation - Ex. 1039, p. 2
`
`
`
`CGI Applications
`
`3
`
`Figure 1-2. Simple form illustrating different widgets
`
`CGI program can process this information and return document(s) that match the
`user’s selection criteria.
`
`Chapter 4, Forms and CGI, discusses forms in detail, and Chapter 7, Advanced
`Form Applications, shows examples of incorporating forms into several robust
`applications.
`
`Gateways
`
`Web gateways are programs or scripts used to access information that is not
`directly readable by the client. For example, say you have an Oracle database that
`contains baseball statistics for all the players on your company team and you
`would like to provide this information on the Web. How would you do it? You
`
`Petitioner Microsoft Corporation - Ex. 1039, p. 3
`
`
`
`....................... m
`
`Chapter 1: The Common Gateway Interface (CGI)
`
`Y
`
`certainly cannot point your client to the database file (i.e., open the URL associ-
`ated with the file) and expect to see any meaningful data.
`
`CGI provides a solution to the problem in the form of a gateway. You can use a
`language such as oraperl (see Chapter 9, Gateways, Databases, and Search/Index
`Utilities, for more information) or a DBI extension to Perl to form SQL queries to
`read the information contained within the database. Once you have the informa-
`tion, you can format and send it to the client. In this case, the CGI program serves
`as a gateway to the Oracle database, as shown in Figure 1-3.
`
`ORACLETM Database
`
`-- Request
`
`Request
`
`/
`
`Failed Request
`
`Figure 1-3. A gateway to a database
`
`Similarly, you can write gateway programs to any other Internet information
`service, including Archie, WAIS, and NNTP (Usenet News). Chapter 10, Gateways
`to Internet Information Servers, shows examples of interacting with other Internet
`services. In addition, you can amplify the power of gateways by using the forms
`interface to request a query or search string from the user to retrieve and display
`dynamic, or virtual, information. We will discuss these special documents next.
`
`Virtual Documents
`
`Virtual, or dynamic, document creation is at the heart of CGI. Virtual documents
`are created on the fly in response to a user’s information request. You can create
`virtual HTML, plain text, image, and even audio documents. A simple example of
`a virtual document could be something as trivial as this:
`
`Petitioner Microsoft Corporation - Ex. 1039, p. 4
`
`
`
`Some Working CGI Applications
`
`Welcome to Shishir’s WWW Server!
`You are visiting from diamond.com. The load average on this machine is
`1.25.
`Happy navigating!
`
`In this example, there are two pieces of dynamic information: the alphanumeric
`address (IP name) of the remote user and the load average on the serving
`machine. This is a very simple example, indeed!
`
`On the other hand, yew complex virtual documents can be created by writing
`programs that utilize a combination of graphics libraries, gateways, and forms. As
`a more sophisticated example, say you are the manager of an art gallery that
`specializes in selling replicas of ancient Renaissance paintings and you are inter-
`ested in presenting images of these masterpieces on the Web. You start out by
`creating a form that asks for user information for the purpose of promotional mail-
`ings, presents a search field for the user to enter the name of a painting, as well
`as a selection list containing popular paintings. Once the user submits the form to
`the server, a program can email the user information to a certain address, or store
`it in a file. And depending on the user’s selection, either a message stating that
`the painting does not exist or an image of the painting can be displayed along
`with some historical information located elsewhere on the Internet.
`
`Along with the picture and history, another form with several image processing
`options to modify the brightness, contrast, and/or size of the picture can be
`displayed. You can write another CGI program to modify the image properties