Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why CGI is used?

 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am learning about servlets and JSP... In that process i read(very little) how CGI(scripting) works . I read that for every request that a CGI receives it creates a new heavy weight thread but in servlets it not the case it only creates a light weight thread. I felt that creating a heavy weight threadfor every request by CGI can be considered as a very valid drawback. BUT still CGI programs are used extensively. So there must be some thing in CGI that is a real good advantage that is masking the above mentioned disadvantage.
What is THAT advantage ???
Are there any similar disadvantage in using servlets ???
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I don't see CGI still being used extensively. But regardless, the barrier to entry is very low as no language like Java needs to be learned.
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Well, I don't see CGI still being used extensively. But regardless, the barrier to entry is very low as no language like Java needs to be learned.

Oh...
i thought CGI is more used than servlets....
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's impossible to tell from the URL whether CGI is or isn't used. Even if the URL contains a string "cgi" or "cgi-bin" or some such, that may just be for historical purposes, while the actual CGI mechanism has long been replaced by a more modern approach.
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:It's impossible to tell from the URL whether CGI is or isn't used. Even if the URL contains a string "cgi" or "cgi-bin" or some such, that may just be for historical purposes, while the actual CGI mechanism has long been replaced by a more modern approach.

Oh... i never knew this... Actually i used to think if the url has something like "cgi" or "cgi-bin" then CGI is used.
With what did they replace it..

If they have replaced then why is that in the head first servlets book they still talk about that heavy weight issue???
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually i used to think if the url has something like "cgi" or "cgi-bin" then CGI is used. With what did they replace it..

CGI is mainly used for transferring handling of a web request to an external process (like a Perl interpreter). Modern servers (like GlassFish and Tomcat) handle all that internally, though, with no external processes to fire up. And even if more than one process is involved (like in an Apache httpd/Tomcat combination, or if using FastCGI), both processes are running already, which makes for much smaller overhead.

If they have replaced then why is that in the head first servlets book they still talk about that heavy weight issue?

It would help if you quoted the passage you're talking about.
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HF servlets, pageno :28 wrote:Performance,for one thing.With Perl,the server has to launch a heavy weight process for each and every request for that resource

Actually, this is part of a conversion between CGI and servlets.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That statement in HFSJ isn't quite accurate. Mechanisms like FastCGI are available that do NOT launch a new child process for each request. That's also true when using mod_perl with Apache httpd.
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ulf Dittmer, i would go ahead and try to understand more about FastCGI.
And one more thing , i also want to know , which is used more CGI or servlets( percentage).
i know its a stupid question, it would really depend on the situation . But still you would have (i guess) noticed it.
Can you tell in terms of % ??
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I mentioned above, there's no way to tell from a URL if CGI is used, or if servlets are used, or if some other technology I used. So I'm not aware of any statistics about that.
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok..
Thanks buddy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic