- World's Largest Collection of Interview Questions
Start Your Own website Now
Sponsored Links

Interview Questions
Our Services

Get 9,000 Interview Questions & Answers in an eBook.

  • 9500+ Pages
  • 9000 Question & Answers
  • All Tech. Categories
  • 14 MB Content

    Get it now !!

    Send your Resume to 6000 Companies

    Question :
    What is the difference between CGI and Servlet?
    Category Java Interview Questions
    Rating (0.4) By 1027 users
    Added on 5/25/2006
    Views 3481
    Rate it!

    CGI creates process for each client call where as servlet creates process for the first time and then uses thread for each client.

    Submitted by Sunanda Yugandhar (

    CGI can respose for only one request at a time.but in servlet so many request at a time.

    Posted by: Amala    

    Contact Amala Contact Amala

    cgi program or script may be platform independent.but servlet is may not be platform indpendent.

    Posted by: adroja zinkal    

    Contact adroja zinkal Contact adroja zinkal

    CGI:It is difficult to control the security previleges of servlet
    servlet:It control security previleges of servlet

    Posted by: vandana    

    Contact vandana Contact vandana

    Servlet CGI (Common Gateway Interface)
    Servlets can link directly to the Web server. CGI cannot directly link to Web server.
    Servlets can share data among each other. CGI does not provide sharing property.
    Servlets can perform session tracking and caching of previous computations. CGI cannot perform session tracking and caching of previous computations.
    Servlets are portable. CGI is not portable.
    In Servlets, the Java Virtual Machine stays up, and each request is handled by a lightweight Java thread. In CGI, each request is handled by a heavyweight operating system process.
    Servlets automatically parse and decode the HTML form data. CGI cannot automatically parse and decode the HTML form data.
    Servlets can read and set HTTP headers, handle cookies, tracking sessions. CGI cannot read and set HTTP headers, handle cookies, tracking sessions.
    Servlets is inexpensive than CGI. CGI is more expensive than Servlets.

    Posted by: Maneesh Tiwari    

    Contact Maneesh Tiwari Contact Maneesh Tiwari

    Difference between CGI and Servlet:
    CGI (Common gateway interface) Servlet
    1. CGI is platform dependent Servlet is platform independent
    2. CGI creates a new process for each request. Servlet creates a thread for each request and service the request in that thread.
    3. CGI is not based on pooling (which hold no external resource but occupy memory i.e. not destroy after used) Its container managed pooling object.
    4. CGI has no session tracking mechanism It supports session tracking mechanism
    5. For each process created by CGI the process assign the separate address. so there is memory overload on the server For each thread created by Servlet no separate address space is created. All thread operates in the same parent address space (it is created when Servlet is load at first time). so there is no memory overload on the server
    6. CGI Build with scripting languages (like C, C++, Perl etc) Servlet build with java

    Posted by: Shiv    

    Contact Shiv Contact Shiv

    1.It is a ?process based? that is for every request a separate process will be created and that is responsible to generate the response.

    2.Creation and destruction of new process for every request is costly. If the no. of requests increases, the performance of the system goes down. Hence CGI technology fails to deliver Scalable Applications.

    3.Two processes never share the common address space. Hence concurrency never comes in CGI technology.

    4.CGI programming can be written in multiple languages. Mostly common used languages PERL

    5.Most of the CGI languages are not object oriented. Hence we may miss the benefit of the OOPS.

    6.CGI technology is platform dependent.

    1.It is ?Thread based? that is for every client request a separate thread will be created and that is responsible for generation of dynamic response.

    2.Creation and destruction of a new thread for every request is not Costly. Hence even though no. of requests increases there is no change in the response time and performance. Hence Servlet Technology succeeds to deliver Scalable Applications

    3.All the Threads share the same common address space. Hence concurrency problems may rise.

    4.Servlet should be written in Java only.

    5.Java languages itself object oriented. Hence we can get all benefit of the OOPS.

    6.Servlet technology is platform independent.

    Posted by: himanshu sharma    

    Contact himanshu sharma Contact himanshu sharma

    Set your own life easier take the <a href="">home loans</a> and everything you need.

    Posted by: SHARPEBobbi27    

    Contact SHARPEBobbi27 Contact SHARPEBobbi27

    If you have the better answer, then send it to us. We will display your answer after the approval.
    Rules to Post Answers in

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
  • Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification  Enter the above shown code:*
    Inform me about updated answers to this question

    Related Questions
    View Answer
    What is the use of Interface?
    View Answer
    Why Java is not fully object oriented?
    View Answer
    Why does not support multiple Inheritance?
    View Answer
    What it the root class for all Java classes?
    View Answer
    What is polymorphism?
    View Answer
    Suppose If we have variable ' I ' in run method, If I can create one or more thread each thread will occupy a separate copy or same variable will be shared?
    View Answer
    In servlets, we are having a web page that is invoking servlets username and password. which is cheks in the database, Suppose the second page also. If we want to verify the same information whether it will connect to the database or it will be used previous information?
    View Answer
    What are virtual functions?
    View Answer
    Write down how will you create a binary Tree?
    View Answer
    What are the traverses in Binary Tree?
    View Answer
    Write a program for recursive Traverse?
    View Answer
    What are session variable in Servlets?
    View Answer
    What is client server computing?
    View Answer
    What is Constructor and Virtual function. Can we call Virtual funciton in a constructor?
    View Answer
    Why we use OOPS concepts, What is its advantage?
    View Answer
    What is the middleware. What is the functionality of Webserver?
    View Answer
    Why Java is not 100 % pure OOPS?
    View Answer
    When we will use an Interface and Abstract class?
    View Answer
    What is an RMI?
    View Answer
    How will you pass parameters in RMI. Why u serialize?
    View Answer

    Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here - Best Freshers & Experienced Jobs Website.

    View ALL Java Interview Questions

    User Options
    Sponsored Links

    Copyright ©2003-2015, All Rights Reserved.
    Privacy Policy | Terms and Conditions

    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Dedicated Servers | C Interview Questions & Answers

    Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes

    Cache = 0.015625 Seconds