The CGI
Home ] Up ] [ The CGI ] The URLConnection Class ]

 

InfoSpace Example
Google Maps Example
Get & Post

 

The Common Gateway Interface (CGI) is a very common mechanism for communicating between a web browser and a web server. Typically, the steps are:

  1. The user fills in a form, which typically has input fields such as text fields, and lists, checkboxes, etc.
  2. The user submits the data from the form, typically using a Submit button or similar mechanism
  3. The web browser sends the data to the web server.
  4. The web server sends the data to a CGI script.
  5. The CGI script processes the form data and dynamically generates an HTML page
  6. The web server passes the HTML page back to the browser
  7. The web browser displays the HTML page, which are the results of the query.

CGI scripts may be written in a number of different languages, including Java, perl, C, etc.

CGI Queries

Many web sites allow you use a CGI query

A CGI query is:

  1. A regular URL, followed by
  2. A question mark (?), followed by
  3. A query string

A query string is a set of name/value pairs:

name=value

with each name/value pair separated from the next with an ampersand (&) character.

For example:

http://www.google.com/search?q=cgi+query&sourceid=ie7&rls=com.microsoft:en-US&ie=utf8&oe=utf8

which comprises the following sets of name/value pairs:

  • q=cgi+query
  • sourceid=ie7
  • rls=com.microsoft:en-US
  • ie=utf8
  • oe=utf8
 
The page was last updated February 19, 2008