what is the advantage of using Servlets over CGI programming?

Answers were Sorted based on User's Feedback



what is the advantage of using Servlets over CGI programming?..

Answer / mdsha_asiya

The problem with CGI script is that your server must
restart the CGI script every time a new request is
issued.This means every time a client communicates,your
server needs to begin a new proccess .starting and stopping
processes are expensive operions.
The difference between servlet and CGI scritpt is that CGI
script must be restarted every request where as servlets
are pooled and reused over and over again to service many
requests.This means you don't have to restart a process
every time client request comes over the network.

After servlet is loaded,to handle client request it simply
creates a thread and runs service() of servlet.


servlets are more efficient,powerful,portable,inexpensive
and convinent.

Is This Answer Correct ?    14 Yes 2 No

what is the advantage of using Servlets over CGI programming?..

Answer / janet

Servlets are only instantiated when the client first
accesses the program. All subsequent accesses are done to
that instance.This keeps the response time of servlets lower
than that of CGI programs, which must be run once per
hit.also because servlet is instantiated only once,all
accesses are put through that one object. This helps in
maintaining objects like internal connection,pooling or user
session tracking and lots of other features.

Is This Answer Correct ?    11 Yes 0 No

what is the advantage of using Servlets over CGI programming?..

Answer / sandeep m

CGI programs need separate process to process a request.
For which CGI object has to be created and destroyed for
each request or else pool of processes can be maintained by
server and for each request a process is assigned by server
which will be returned back to server after request
processing.
Servlets use Threads. Due to which single Servlet object is
created. Whenever a request is received by server a new
thread is created and the thread uses the existing Servlet
instance.
Advantage is process creation is heavy weight. Threads are
light weight. Burden of creating and destroying processes
is reduced or else maintaining process objects in pool is
reduced. Any number of requests can be served with not much
burden on server

Is This Answer Correct ?    4 Yes 1 No

what is the advantage of using Servlets over CGI programming?..

Answer / ravat

There is only one main difference between CGI and Servlet that CGI is not that much efficient as servlets ,because Wen each time request cames to CGI it ll start from first i.e loading,instantiation and ll consume more time but in the case of Servlet only once server is loaded and instance is created and it is reused to other request and wenever the new request cames just it ll make use of same object

Is This Answer Correct ?    3 Yes 3 No

Post New Answer

More Servlets Interview Questions

What do you mean by httpservlet and how it is different from the genericservlet?

0 Answers  


What's the advantages using servlets than using cgi?

0 Answers  


Why do we use sendredirect() method?

0 Answers  


how many jsp scripting elements are there and what are those?

0 Answers  


hi.... i have problem in running of servlet. i am using Tomcat server in my pc.. The problem is when i am click on strat it will display like below FAIL - Application at context path /first could not be started.. How i can slove the problem.. help plz

3 Answers  






How are filters?

0 Answers  


What do you mean by default initialization in java servlet?

0 Answers  


What is the default http method in the servlet?

0 Answers  


What is a servlet-to-servlet communcation?

0 Answers  


what is the advantage of using Servlets over CGI programming?

4 Answers  


What is the difference between Servlets and Applets?

0 Answers  


How the typical servlet code look like ?

0 Answers  


Categories