Common Gateway Interface (CGI)

CGI, or Common Gateway Interface, is a standard mechanism for communication between Web servers and server-side gateway programs that was developed in the UNIX networking environment.

What is CGI (Common Gateway Interface)?

CGI - A standard mechanism for communication between Web servers and server-side gateway programs that was developed in the UNIX networking environment. These gateway programs are written either in a compiled language such as C or in an interpreted language such as Perl. Common Gateway Interface (CGI) allows Web servers to run scripts or programs on the server and send the output to the client Web browser.

How It Works: Common Gateway Interface

When a Web client such as Microsoft Internet Explorer submits a form or otherwise passes information to a Web server using CGI, the Web server receives the information from the client and passes it to the gateway program for processing. The gateway program then returns the result of the processing to the server, which returns it to the Web browser as an HTML page.

CGI applications are often used as form handlers for Web forms, and are executed using a <FORM> tag embedded in the form document, as in the following:

<FORM METHOD=POST ACTION=
"http://www.northwind.microsoft.com/cgi-bin/results.pl">

In this example, the Perl script results.pl in the cgi-bin directory functions as the form handler for processing the information submitted using the form.

NOTE

CGI was developed for UNIX-based systems and is supported by most Web servers, including Internet Information Services (IIS). Microsoft Internet Server API (ISAPI) is a set of server extensions for IIS that functions similar to those of CGI but uses fewer resources. The main difference is that with CGI the system creates a unique process for every CGI request, while ISAPI extensions do not require separate processes. This makes ISAPI applications generally more responsive than CGI applications.