Common Gateway Interface (CGI)

[ CGI - Links ]   [ Web Computing ]   [ Web Programming ]   [ HOME ]

With the advent of the Web and graphical Web browsers, the Internet gained tremendous popularity. This greatly increased the volume of requests users made for information from Web servers. It became clear that the degree of interactions between the user and the server would be crucial. The power of Web servers is not only serving the static content to users, but also in responding dynamically. The framework for such communication had been established through CGI.

Common Gateway Interface (CGI) is a standard protocol through which server-side applications (scripts) interact with Web servers. Thus CGI provides a way for clients, that is, Web browsers, to indirectly interface with applications on the Web server. These applications are mainly used for generating dynamic web pages on the basis of user information. Often CGI scripts utilize and process information, such as a search engine query, a credit card number, etc. supplied by an user through HTML forms. For example, a CGI script could verify credit-card information and notify the client of the results. Thus apart from their assigned tasks, a CGI script can access database if necessary before sending the result to Web server, which in turn send it to the Web browser.

Because CGI is an interface, a script or executable program must be developed using any one of the several scripting or programming languages. The point here is the scripts thus developed should have implemented the methods of the interface so that Web servers can at point of time access the applications to serve the needs of clients. The main scripting language being used nowadays is Perl.

Practical Extraction and Report Language (Perl) is one of the most widely used languages for Web programming today. Larry Wall began developing this high-level programming language in 1987. His initial goal was to create a programming language to monitor large software projects and generate reports. The other goals are that Perl would be more powerful than shell scripting and more flexible than C and consist of many rich text-processing capabilities and most of all, it should make common programming tasks straightforward and easy.

As most of the information users send to Web servers is text, Perl became a logical choice for CGI programming due to its simple, yet powerful, text processing capabilities.