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 are the differences between servlet context vs servlet config?

0 Answers  


Why doesn’t a servlet include main()? How does it work?

0 Answers  


I have a requirement Here we have a ResultSet object that will contain 50 records i need to print those recors in to a webpage(i.e; view according to MVC architectures that mybe servlet or jsp) . Here i need to print the records 10 per page that is 1 to 10 in page one and 11 to 20 in page two like remaining will be appeared in other pages we need to display those page numbers whenever we click on that page number we will go to that page and display 10 records like we will display 5 pages it is like this << 1 2 3 4 5 next >>

0 Answers   ProKarma,


What is the life cycle of a servlet?

1 Answers  


When Servlet is unloaded?

0 Answers  






What are sessions in servlets?

0 Answers  


Tell us something about servletcontext interface.

0 Answers  


Explain the different ways for servlet authentication?

0 Answers  


What are the types of an http request?

0 Answers  


What are session variable in servlets?

0 Answers  


What is DSN and System DSN and what is the difference between them?

2 Answers  


Write a command to get actual path of a servlet to the server?

0 Answers  


Categories