• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » Html » Tutorial » What is CGI? | Common Gateway Interface Definition
Next →
← Prev

What is CGI? | Common Gateway Interface Definition

By Dinesh Thakur

The Common Gateway Interface (CGI) is a specification defined by the World Wide Web Consortium (W3C), defining how a program interacts with a Hyper Text Transfer Protocol (HTTP) server. The Common Gateway Interface (CGI) provides the middleware between WWW servers and external databases and information sources. CGI applications perform specific information processing, retrieval, and formatting tasks on behalf of WWW servers.

We’ll be covering the following topics in this tutorial:

  • Why is CGI used? 
  • Working of CGI (Common Gateway Interface)

Why is CGI used? 

An interesting aspect of a CGI enabled Web server is that computer programs can be created and deployed that can accept user input and create a webpage on the fly. Unlike static Web pages that display some preset information, these interactive web pages enable a client to send information to the Web server and get back a response that depends on the input.

A Web search engine is a good example of an interactive web page. The client enters one or more keywords, and the Web index returns a list of Web pages that satisfy the search criteria entered. The Web page returned by the Web index is also dynamic, because the content of that page depends on what the client types in as search words – it’s not a predefined static document.

To create an interactive Web page, HTML elements are used to display a form that accepts a client’s input and passes this to special computer programs on the Web server, These computer programs process a client’s input and return requested information, I usually in the form of a web page constructed on the fly by the computer program.

These programs are known as gateways because they typically act as a conduit between the Web server and an external source of information, such as a database. Gateway programs I exchange information with the Web server using a standard known as The Common Gateway Interface. This is the reason CGI programming is used to describe the task of writing computer programs that handle client requests for information.

The term gateway describes the relationship between the WWW server and external applications that handle data access and manipulation chores on its behalf. A gateway interface handles information requests in an orderly fashion, and then returns an appropriate response. For example, an HTML document generated on the fly which contains the results of a query applied against an external database.

In other words, CGI allows a WWW server to provide information to WWW clients that would otherwise not be available to those clients. This could, for example, allow A www client to issue a query to an Oracle database and receive an appropriate response in the form of a custom built Web document. Some common uses of CGI include: Gathering user feedback about a product line through an HTML form. Querying an Oracle database and rendering the result as an HTML document.

Working of CGI (Common Gateway Interface) Common Gateway Interface

As shown in the above figure, a Web browser running on a client machine exchanges information with a Web server using the Hyper Text Transfer Protocol or HTTP. The Web server and the CGI program normally run on the same system, on which the web server resides, Depending on the type of request from the browser, the web server either provides a document from its own document directory or executes a CGI program.

The sequence of events for creating a dynamic HTML document on the fly through CGI scripting is as follows:

1. A client makes an HTTP request by means of a URL. This URL could be typed into the ‘Location’ window of a browser, be a hyperlink or be specified in the ‘Action’ attribute of an HTML <form> tag.

2. From the URL, the Web server determines that it should activate the gateway program listed in the URL and send any parameters passed via the URL to that program.

3. The gateway program processes the information and returns HTML text to the Web server. The server, in turn, adds a MIME header and returns the HTML text to the Web browser.

4. The Web browser displays the document received from the Web server.

You’ll also like:

  1. What is HDMI (High-Definition Multimedia Interface)?
  2. What is a Fiber Distributed Data Interface (FDDI)? – Definition
  3. What does the common dialog box means? Explain types of common dialog boxes
  4. What is difference between SERVLET and CGI?
  5. What is Gateway? Characteristics of Gateways.
Next →
← Prev
Like/Subscribe us for latest updates     

About Dinesh Thakur
Dinesh ThakurDinesh Thakur holds an B.C.A, MCDBA, MCSD certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps.

Dinesh Thakur is a Freelance Writer who helps different clients from all over the globe. Dinesh has written over 500+ blogs, 30+ eBooks, and 10000+ Posts for all types of clients.


For any type of query or something that you think is missing, please feel free to Contact us.


Primary Sidebar

HTML Tutorials

HTML Tutorials

  • HTML - Home
  • HTML - History
  • HTML - Lists
  • HTML - Unordered List
  • HTML - Ordered Lists
  • HTML - Frame Tag
  • HTML - Input Type
  • HTML - Input Type="File"
  • HTML - Input Type="Hidden"
  • HTML - Form Tag
  • HTML - Img Tag
  • HTML - Anchor Tag
  • HTML - Table Tag
  • HTML - Span Tag
  • HTML - Button Tag
  • HTML - Doctype
  • HTML - Fieldset Tag
  • HTML - Links Tag
  • HTML - Drop Down Menu
  • HTML - Accesskey
  • HTML - Cgi
  • HTML - Post Method
  • HTML - Background Image
  • HTML - Text Area
  • HTML - TabIndex
  • HTML - Align Center
  • HTML - Address Tag
  • HTML - Thumbnails
  • HTML - Marquee Tag
  • HTML - Line Break
  • HTML - Blockquote
  • HTML - HR Tag
  • HTML - Image Center
  • HTML - Center Text
  • HTML - Link CSS
  • HTML - Html Vs Html5

Other Links

  • HTML - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW