Different between Servlet and CGI

Different between Servlet and CGI


Posted in : Servlet Posted on : October 29, 2010 at 5:00 PM Comments : [ 0 ]

In this tutorial you will larn the differences between Servlet and CGI programs

Different Between Servlet And CGI

Common Gateway Interface (CGI) is a standard protocol used by the server to pass the client request to the application and from application to the user. The CGI script can be written in perl, C, C++, UNIC Shell Scripts etc. When the request comes from the client, it creates a new process allocate to the client. This takes an overhead of creating a new process for every request. Suppose when there are may clients requesting then you can imagine the result.

 

CGI Script handling requests

A Servlet is also a java version of CGI, which written in java. It takes the advantages of java to handle the client request. When the server started it initiates the servlet and keep into the memory. The servlet creates only one process and uses uses thread for handling the client request. When a new request come from the client it create a new thread for that client and allocate them. It does not takes the overhead of creating new process for each client, which is takes more memory in compare to creating a new thread. Because thread is lighter than the process.

 

Servlet handling a request

CGI is capable for handling only one client request at a time, and its script can be platform dependent because it may be written C, C++, perl, UNIX Shell etc.While servlet can handle may request at a time and its is platform independent.

The main differences between servlet and CGI is processing. For every request CGI initiate itself and create a new process. While the Servlet is only once initiated can be capable for handling many requests. CGI creates a processes for every client request, while Servlet creates a Thread for each request, therefore CGI is slower than the Servlet.

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics