Results for Common Gateway Interface
On this page:
 
(¦sē¦jē′ī ′skript)

(computer science) A program, written in a language such as Perl, that is used for creating interactive Web pages; for example, it allows a Web server to process a request from a user, communicate with a database, and reply to the user by creating a Web page.


 
 

(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.

Web Server Evolution
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.



 
Wikipedia: Common Gateway Interface

The Common Gateway Interface (CGI) is a standard protocol for interfacing external application software with an information server, commonly a web server. This allows the server to pass requests from a client web browser to the external application. The web server can then return the output from the application to the web browser.

History

CGI arose out of discussions on the www-talk mailing list between Rob McCool, John Franks, Ari Luotonen, George Phillips and Tony Sanders in 1993. Rob McCool, working at NCSA, drafted the initial specification and provided a reference implementation in the NCSA HTTPd web server using environment variables to store parameters passed from the web server execution environment before spawning the CGI program as a separate process.

Example

An example of a CGI program is the one implementing a wiki. The user agent requests the name of an entry; the server will retrieve the source of that entry's page (if one exists), transform it into HTML, and send the result back to the browser or prompt the user to create it. All wiki operations are managed by this one program.

Implementation

The way CGI works from the Web server's point of view is that certain locations (e.g. http://www.example.com/wiki.cgi) are defined to be served by a CGI program. Whenever a request to a matching URL is received, the corresponding program is called, with any data that the client sent as input. Output from the program is collected by the Web server, augmented with appropriate headers, and sent back to the client.

Because this technology generally requires a fresh copy of the program to be executed for every CGI request, the workload could quickly overwhelm web servers, inspiring more efficient technologies such as mod_perl or PHP that allow script interpreters to be integrated directly into web servers as modules, thus avoiding the overhead of repeatedly loading and initializing language interpreters. However, this is only applicable for high-level languages that need interpreters. Such overloads can be avoided by utilizing languages like C. By using C or similar compiled languages it is possible to reach higher efficiency levels, because such programs terminate their execution cycle faster than interpreted languages with less operating system overhead. Even better, RPG programs on the IBM iSeries/AS400 may stay resident in memory with databases already open, allowing for faster execution on subsequent usage. The optimal configuration for any web application will obviously depend on application-specific details, amount of traffic, and complexity of the transaction; a software engineer analyzes these tradeoffs to determine the best implementation for a given task and budget.

Web servers often have a cgi-bin directory at the base of the domain, to hold executable files.

Workarounds for scripting languages

The overhead of spawning new processes to compile the server code can be easily handled if the code is only changed occasionally. One example is FastCGI, while others include programming accelerators that take a web script when initially called and store a compiled version of the script in a system location so that further requests for the file are automatically directed to the compiled code instead of invoking the script interpreter every time the script is called. When scripts are changed, the temporary accelerator cache can be emptied to ensure that the new script is called instead of the old one. Thus for languages such as C or Pascal or RPG, which are usually compiled anyway, CGI programs are no different from other programs in this regard, and require no special processing. Another approach used for scripting languages is to embed the interpreter directly into the web server so that it can be executed without creating a new process. Modern web servers like Apache or Cherokee have a number of modules for Perl, PHP, Python and Ruby which do this.

References

See also

External links


 
 

Join the WikiAnswers Q&A community. Post a question or answer questions about "Common Gateway Interface" at WikiAnswers.

 

Copyrights:

Sci-Tech Dictionary. McGraw-Hill Dictionary of Scientific and Technical Terms. Copyright © 2003, 1994, 1989, 1984, 1978, 1976, 1974 by McGraw-Hill Companies, Inc. All rights reserved.  Read more
Computer Desktop Encyclopedia. THIS COPYRIGHTED DEFINITION IS FOR PERSONAL USE ONLY.
All other reproduction is strictly prohibited without permission from the publisher.
© 1981-2008 Computer Language Company Inc.  All rights reserved.  Read more
Wikipedia. This article is licensed under the GNU Free Documentation License. It uses material from the Wikipedia article "Common Gateway Interface" Read more

Search for answers directly from your browser with the FREE Answers.com Toolbar!  
Click here to download now. 

Get Answers your way! Check out all our free tools and products.

On this page:   E-mail   print Print  Link  

 

Keep Reading

Mentioned In: