Servlet Menu


Common Gateway Interface(CGI) vs Servlet




Common Gateway Interface

The Common Gateway Interface (CGI) provides the middleware between servers and external databases or information sources. The Web server typically passes the form information to a small application program that processes the data and may send back a confirmation message. This process or convention for passing data back and forth between the server and the application is called the common gateway interface. The following image describes how a web server acts as an intermediate between the CGI program and the client browser.

CGI Architecture

A new process is started for each client request. The creation of the process for every such request requires time and significant server resources which limits the number of requests a server can handle


Servlet

Servlets are server based java application that can link directly to the Web server. Servlets are thread based applications and work on server level and they share data among each other. All the programs of Servlets are written in JAVA and they get to run on JAVA Virtual Machine. The following image describes how a request from clients is served with the help of threads:

CGI Architecture

CGI

Servlet

The CGI programs are written in native OS. Servlet is written in java class & its runs in JVM.
CGI creates a process base for each request. Servlet creates a new thread to process each request.
The CGI is a language-independent interface that allows a server to start an external process. The main purpose of servlets is to add up the functionality to a web server.
A CGI program needs to be loaded and started on each CGI request. Servlets stay in the memory while serving the requests.
CGI is not able to read the HTTP servers. Servlets are useful to read and set the HTTP servers.
CGI are plateform dependent. Servlets are plateform independent.
Servlets are more secure and useful for Data sharing. CGI is less secure and is not useful for data sharing.

Next Topic :Servlet Life Cycle

Suggestion/Feedback Form :




Excellent  Very Good  Good  Average  Poor


This is a Compliment
This is a Suggestion for improvement
This is Feedback
This is Grievance