What is difference between cgi and servlet in interview point?

Showing Answers 1 - 7 of 7 Answers

Anuj Kumar Ratra

  • Mar 9th, 2006
 

CGI spawns a new instance to  cater to every request whereas servlets there is only one instance and a new light weight thread is spawned to cater to every request i.e there is only one set of instance variables in servlets

  Was this answer useful?  Yes

ak40732

  • Mar 25th, 2006
 

1.CGI creates a new process for each request,Whereas Servlet creates a thread for each request and services the request in that thread.

2.For each process created by CGI,the process is assinged seperate address space.SO there is memory overload on the server.Whereas for every thread created by the servlet,no seperate address space is created,all threads operate in the same parent process address space.so there is no memory overlaod.

3.CGI is not based on pooling,Whereas servlet are container managed pooled objects.

  Was this answer useful?  Yes

nagan

  • Apr 6th, 2006
 

CGI(Common Gateway Interface) is framed to implement request/response paradigm with a language like perl but CGI is a not truely object oriented.In CGI decoding is explicit and it is a Process based for every request it creates new process.

Servlets are framed to implement request/response pattern.Servlets are completly written in java.Servlets are truely object oriented and decoding is implicit.Servlets are Thread based

  Was this answer useful?  Yes

Ravi_Times

  • Jun 6th, 2006
 

1. In CGI code interpretaion exists for each and every request, whereas in Servlets exists only once.2. CGI has no Session Tracking, where as Servlets supports Session Tracking mechanism.3. CGI build in C, C++, Perl which are not completly independent whereas Servlets build with Java api.

  Was this answer useful?  Yes

siva kumar reddy

  • Jul 31st, 2006
 

CGI and Servlets are used to develop web application only. CGI is a oldest technique and the main drawback of CGI is
1. Starting process is very expensive
2. It performs very poor.

  Was this answer useful?  Yes

Amit Udiya

  • Feb 27th, 2012
 

Each time whenever a request comes to a CGI from server,it opens a new connection for that request.If a number of clients make request to the same serve,CGI will open a new connection to serve their requests.Hence overhead would be there.Whereas in servlet,only one connection would be open for multiple clients even for same request.It reduces the server overhead,and provide updated and fresh copy of response to the server.This only is in core of servlets invention over CGI.


Thanks
Amit Udiya

  Was this answer useful?  Yes

SUJATA WAGHMARE

  • Jan 10th, 2014
 

before servlet used to technology cgi....but cgi have a drawback...cgi throw send requests to web server..then web server make process for one request...thats why processor not response to the client.....servlet is share comman memory area...this is different between servlet and cgi...

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions