(Common Gateway Interface script) A relatively compact program written in a language such as Perl, Tcl, C or C++ that processes data on a Web server. It is commonly used to process a query from the user that was entered on an HTML page (Web page) and returned as an HTML page, in which case the CGI script functions as the glue between the query and the database. For example, it would pull the search data out of the GET request in the HTML form, look it up in the database management system (DBMS) and format the results as an HTML page that is sent back to the user.|
CGI scripts were the initial mechanism used to make Web sites interact with databases and other applications. However, as the Web evolved, other server-side processing methods were developed that are more efficient than CGI, such as Active Server Pages (ASPs), JavaServer Pages (JSPs) and servlets. See ASP, JSP, servlet and FastCGI.
Starting at the top and moving down, this illustration shows Web and application server processing as it evolved initially using only CGI scripts and later using Java components. The separation of logic is portrayed here, and the Web server (HTTP server) and application server may reside in the same or different computers.