Previous Page TOC Next Page

Common Gateway Interface

The Common Gateway Interface (CGI) is used to run external programs, or gateways, from an information server. Web servers are currently the only known servers to use this interface.

What is CGI?

The Common Gateway Interface (CGI) is an interface for running external programs, or gateways, from an information server. Web servers are currently the only known servers to use this interface.

What is a CGI Program?

A CGI program handles information requests and returns the appropriate document or generates a document dynamically as needed. A CGI program processes browser requests and returns the appropriate information in a form usable by the browser.

A CGI program, or gateway, is an executable program or command procedure run on a Web server. The program is triggered by input from a browser and is a link between the server and some other program running on the system.

Depending on what your Web server supports, CGI programs can be command procedure or compiled programs.

CGI programs can impact the performance and security of your Web server. Because a CGI program runs on your server each time the browser requests a CGI program, CPU time, memory, and system resources are used. Many CGI programs running at the same time could overload the system so careful planning is required.

Using CGI programs can create security problems. The programs need to be written very carefully, otherwise, someone could break into or damage your system by passing arguments to your program that differ from those expected.

How Are CGI Programs Used?

CGI programs can be used to extend the Web server's capabilities beyond just delivering existing documents. CGI programs allow documents to be generated dynamically; these documents can report current system status, display database records, or even return a variety of existing documents based on complex criteria. Often, CGI programs are associated with HTML forms. They can process the data entered into an HTML form and even generate the forms or additional forms based on the data entered.

For example, CGI programs could be used to query a database. The first form might be used to request a listing of potential records. Once that form is submitted, a second form (or document) is displayed with the matching records. A user can then click on one of the listed records and display or delete that record. Other forms are used to enter new records, modify existing records, or generate reports.

Many applications that are presently character-cell based or use graphical user interfaces, such as X-Windows, can be implemented to run over the Web. The advantages of using the Web to deliver these applications is that Web browsers are available for almost any platform and thus a consistent user interface is available to a very broad user community. And, because many users are already familiar with using browsers, training and learning times are minimized. The Web becomes the common interface to all your applications. By using the Web, users can use these applications from anywhere within your network.

For more information about using CGI programs with forms, see the chapter entitled Forms.



Previous Page Page Top TOC Next Page