Common Gateway Interface, a specification for transferring information between a World Wide Web server and a CGI program. A CGI program is any program designed to accept and return data that conforms to the CGI specification. The program could be written in any programming language, including C, Perl, or Java. CGI programs are the most common way for Web servers to interact dynamically with users. Many HTML pages that contain forms, for example, use a CGI program to process the form’s data once it’s submitted. The programs can be Java applets, Java Scripts, or ActiveX controls which is a common way to provide dynamic feedback for Web users. These technologies are known collectively as client-side solutions. The use of CGI is a server-side solution because the processing occurs on the Web server. One problem with CGI is that each time a CGI script is executed, a new process is started. For busy Web sites, this can slow down the server noticeably. A more efficient solution is to use Java servlets.
How CGI works?
A web browser running on client machine exchanges information with a Web Server using the HyperText Transfer Protocol or HTTP. A client makes an HTTP request by means of a URL. From the URL, the webserver determines that it should activate the gateway program listed in the URL and send any parameters passed via the URL to that program. 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. The Web browser displays the document received from the Web server. The Web browser uses the method attribute of the <form> tag to determine how to send the form’s data to the Web server. We can send data to the data processing page by both the GET and POST methods of a form. Both methods are used in form data handling where each one has some difference in the way they work. The old browsers have a character restriction of 255 in the URL and new ones can handle more than that. But we can’t be sure that all our visitors are using new browsers. So when we show a text area or a text box asking users to enter some data, then there will be a problem if more data is entered. This restriction is not there in the POST method.