previous | start

Common Gateway Interface (CGI)

CGI defines the (original) way in which form data was/is presented to an application program by the HTTP server. There are several newer standards than CGI, but it's still the "default" way of doing Web server-side programming. The examples on the previous slides use the CGI standard interface.
 
When a user clicks the SUBMIT button on a form, the HTTP server starts up the specified CGI program, and makes the form data available to it.
 
From a programming perspective, the difference between GET and POST is the way in which a CGI program receives the form data. If the method was GET, the information is usually obtained by examining the contents of an environment variable (usually called "QUERY_STRING) containing the URL-encoded form data. Other environment variables contain additional useful information.
 
If the method was POST, the CGI program usually receives the form data on its standard input stream, with any extra stuff obtained, as before, from environment variables.
 
CGI programs can, as a rule, be written in any language (compiled or interpreted) supported on the system running the HTTP server.
 
On Unix servers, they are commonly written in Perl, C or as Bourne shell (/bin/sh) scripts.
 
A CGI program (almost) always generates (to standard output) a Web page which is returned to the browser, in addition to any other effect.
 
Lecture 06: Applications #3.2: HTTP Copyright © 2004 P.Scott, La Trobe University Bendigo.

The tutorial for this lecture is Tutorial #06.
La Trobe Uni Logo [Previous Lecture] [Lecture Index] [Next Lecture]
Copyright © 2003 by Philip Scott, La Trobe University.
Valid HTML 3.2!

previous | start