Thursday 14 June 2012

Difference between Servlet and CGI


  • Serverside web resource programs are generally dynamic web resource programs because they generate dynamic we pages when they are requested by browser.

                Server side /Dynamic  web resource programs
                                                |
                    1.process based programs     
                             (CGI Based programs)
   
                     2.Thread Based Programs
                            Servlet Programs
                            JSP Programs


1.process based programs  
  • CGI is a specification to develop server side programs of web application, we can develop these CGI specification based programs in different language like VB,C++,Perl ... etc
  • Perl is the most language most suitable to develop CGI specification base programs
  • Process will be managed by operating system the control jumping (or) context switching between two operating processes is always complex and time consuming job. 
                  CGI Based Example Diagram

  • While working with CGI based server side programs one separate operating system process will be created for every request that is coming to perl program(CGI Based) from the browser window.
  • Every browser window acts as one client to web application since the context switching between operating system processes   takes more time the process based server side programs and their web application are not scaleble. 
  • a scaleble web application gives same performance with irrespective of number of clients that are increased or decreased
2.Thread Based Programs

                ServletBased Example Diagram




  • Programmer develop every servlet program as a java class. when multiple request are given to servlet program only one object of that servlet program will be created and multiple thread will be started on that object representing these multiple request. so servlet program is called as single instance multiple thread based server side component of web application
  • The chain process will be started during server startup and it contains threads representing the request that are coming web resource programs of web application. since context switching between threads of a process takes less time. the thread based server side programs and their web application are quite scalable 
  • Def of Servlet
    •  1.  a servlet program is a java object which can extend the functionality of web server or application server by acting as server side web resource programs of web application 
    • 2. Servlet program is a java based dynamic web resource program of java web application having capabilities to generated dynamic web page.
    • 3. a servlet program is a single instance multiple threads based server side component in java based web application

                                                                   
  
                   

No comments:

Post a Comment