In the realm of computers, a gateway can be several things, including a node that physically connects disparate networks, converting their protocols so they can communicate, or a functional service that provides an intermediary between multiple systems. Gateway programs can act as gateways between server-side resources — like databases — and the web. The Common Gateway Interface (CGI) was the initial mechanism that served as a generic interface between the server and these server-side gateway programs, and was used by most servers to process client requests that required server-side data processing. It is a standard, as well as an interface.
The Common Gateway Interface works in two directions. Suppose that a user sends a request through a web browser, such as submitting an HTML form with data in order to be added to a mailing list. The HTTP server can only serve documents, not process the data. So once the HTTP (HyperText Transfer Protocol) of data to the server is complete, the Common Gateway Interface conveys the data from the server to the gateway program that connects to the database. The results of the processing, such as a confirmation message, are returned to the user traveling on the path in reverse: from the database to the gateway program through the Common Gateway Interface to the server, through HTTP to the user’s web browser.
A Common Gateway Interface script is the name of the software program that was used to process a query to a database. It had the benefit of being operating system agnostic, meaning it would work on a server no matter which operating system it was running. While CGI was much used in the early days of the web, there are now newer, more efficient server-side methods for processing queries, and these are now found as well. These include ASP (Active Server Page) and its newer version ASP.NET (Active Server Page for dot-net, also known as ASP+) and JSP® (JavaServer Page), which allows the combination of HTML (HyperText Markup Language) and Java to work smoothly together on a single web page, but note that ASP is made by Microsoft® and only runs on Microsoft® web servers.
CGI itself has also developed. FastCGI™, an open standard, language-independent extension of CGI that allows for distributed computing, and — unlike CGI — does not exit after each request is complete, but persists, waiting for the next request. SCGI (Simple CGI) is another alternative, both a protocol and a program, placed in the public domain by its creator.