This document was written by CS 290W TA David Corcoran and was last modified
What is CGI?The Common Gateway Interface (CGI) is what allows a Web server to run APPLICATIONS that communicate with Web pages. Remember that Java and JavaScript APPLETS are run on the client. They are downloaded to the Web browser before execution.
CGI is run on the server which makes it especially useful for
applications that need access to files and facilities available on the
server (like databases). CGI applications do not monitor events on
the client. You cannot perform image swapping on the browser using
OnMouseOver events. Refer to the following diagram:
CGI programs can be written in virtually any programming language. The following is a list of a few languages capable of CGI.
One of CGI's most common uses is in processing forms. Take the following form for example:
<FORM ACTION="cgi-bin/guest.cgi" METHOD=POST>This form takes a text value which is default "John". When the user presses the Search Database button, the Web browser will call the Web server at http://icdweb.cc.purdue.edu/ and say "Hey, I need you to execute guest.cgi in directory ~bxd/cgi-bin" and also "I'm going to send you some information to send to that CGI script." In METHOD=POST that information is sent as a data file.
In METHOD=GET that information is known as the QUERY_STRING.
Basically the QUERY_STRING is a string of characters appended to the
end of the URL that it is calling. The previous might actually call:
What is the deal with this Gateway business? The reason it is called Common Gateway is because CGI scripts act as gateways to other programs running on the Web server. Say there is a database running on the machine. I could feasibly do a query on that database using the information passed in by lookfor and present that data back at a Web page to the Client.
For more information on CGI including some commonly used scripts please
visit
http://hoohoo.ncsa.uiuc.edu/cgi/overview.html