Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CGI and servlets

 
ramchander yshetti
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai,

what is CGI(according to my knowledge CGI is process based)
and (Servlets are Thread based) is it write
please clear me
and give me your comment.

bye
 
Amit Kumargupta
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
servlets are excuted as threads and servlets are language independent.
servlet is used to handle request and response .Multiple concurrent request accessing the service method of the same servlet instance,for eg:when a client give a request one instance is created and receive a response from the server,the same client may give a request but it can access the same instance so,it can initialize only once and it cannot create a multiple instance for single client.
so,if we avoid the multiple instance use servlets.

CGI are excuted as process and CGI are language dependent
but for CGI each and every request it can create a new process , so every time it can receive a new request it can create a multiple instance for multiple clients,so it can take more memory address space.
and so servlet is more advantage than CGI.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think Amit has it the wrong way around. Servlets are language-dependent - I'm not aware of any server implementation that uses the term "servlet" except Java.

CGI are a language-independent mechanism of how HTTP requests are bound to server processes. It is (or was) used with many languages, especially Perl.
 
Amit Kumargupta
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
servlets are excuted as threads and servlets are language independent.


CGI are excuted as process and CGI are language dependent.


Hi Ulf Dittmer

I think I am wrong but I read this line (servlets are language independent) in some article.



Can you clear me this point
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Amit Kumargupta:
Can you clear me this point


Could you write a servlet in FORTRAN? COBOL? As a shell script?
 
Amit Kumargupta
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear Bibeault and Ulf Dittmer

Sorry for that. Yes I am wrong.
I apologize for wrong phrase.
 
sunny dhoni
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Amit Kumargupta:
[QB]servlets are excuted as threads and servlets are language independent.
the same client may give a request but it can access the same instance so,it can initialize only once and it cannot create a multiple instance for single client.
so,if we avoid the multiple instance use servlets.


In case of servlets, there is no concept of request coming from single client as far as handling those requests is concerned. every new request (from same client, unless cookies are enabled or from diff client) is considered separate.
a new thread of execution is created for every request and has nothing to do with instances of the servlet. there is always a single instance of servlet irrespective of whether the request is coming from same client or a different client.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"sunny dh", please check your email for an important message from me.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic