The Common Gateway Interface (CGI) is a specification defined by the World Wide Web Consortium(W3C) , defining how a program interacts with a Hyper Text Transfer Protocol(HTTP) server. The Common Gateway Interface (CGI) provides the middleware between WWW servers and external databases and information sources. CGI applications perform specific information processing, retrieval, and formatting tasks on behalf of WWW servers.
Why is CGI used?
An interesting aspect of a CGI enable Web server is that computer program can be created and deployed that can aspect user input and create a Web page on fly. Unlike static Web page that display some preset information, these interactive web pages enable a client to send information to the Web server and get back a response that depends on the input.
A Web search engine is a good example of an interactive web page. The client enters one or more keywords, and the Web index returns a list of Web pages that satisfy the search criteria entered. The Web page returned by the Web index is also dynamic, because the content of that page depends on what the content types in as search words – it’s not a predefined static document.
To create an interactive Web page, HTML elements are used to display a form that accepts a client’s input and passes this to special co9mputer programs on the Web server. These computer programs process a client’s input and return rrquested information, usually in the form of a web page constructed on the fly by the computer program. These programs are known as gateways because the typically act as a conduit between the Web server and an eternal source of information, such as a database.
Gateway programs exchange information with the Web server using a standard known as the common Gateway Interface. This is the reason CGI programming is used to describe the task of writhing computer programs that handle client requests for information.
The term gateway describes the relationship between the WWW server and external applications that handle data access and manipulation chores on its behalf. A gateway interface handles information requests in an orderly fashion, and then returns an appropriate response. For example, an HTML document generated on the fly which contains the results of query applied against an external database.
In other words, CGI allows a WWW server to provide information to WWW clients that would otherwise not be available to those clients. This could, for example, allow a WWW client to issue a query to an Oracle database and receive an appropriate response in the form of custom built Web document.