• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

on efficiency advantage of a webcomponent

 
Ranch Hand
Posts: 898
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Citation from Marty Hall's "Core Servlets and JavaServer Pages"
Similarly, in traditional CGI, if there are N simultaneous requests to the same CGI program, there would be N threads but only a single copy of the servlet class. Finally, when a CGI program finishes handling a request the program terminates. This makes it difficult to cache computations, keep database connections open, and perform other computations that rely on persistent data. Servlets, however remain in memory..."


Why CGI cannot be written contrary to this description? What prohibits to it?
What is "traditional"?
 
Author
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Each time a CGI request is received the web server has to spawn a new process (v.expensive) to handle it.
With Servlet technology, the reusable servlet class is usually already loaded and in memory and ready to server the request.
Dont forget CGI is implemented via a simple script file so theres not much to reuse!
HTH
Dan
 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Dan Jepp:
Hi,
Each time a CGI request is received the web server has to spawn a new process (v.expensive) to handle it.
With Servlet technology, the reusable servlet class is usually already loaded and in memory and ready to server the request.
Dont forget CGI is implemented via a simple script file so theres not much to reuse!
HTH
Dan


As I understand, CGI is just a protocol that specifies how the parameters from the clients can be sent to a process and vice versa. It can even be implented using Java. I read somewhere that some webserver allow the CGI based programs in certain languages to be "always loaded". No need to spawn a whole new process. So what Vanin is saying is right. It can be and has been done.
However, the main benefit of Servlets lies in the fact that you have the whole set of Java APIs to work with. You get the standard advantages of OOP. You get platform independence. And the Java Servlet standard is very functional at a very high level, so you don't have to do much (as compared to Perl, say) to have caching etc.
BTW, you get all that using PHP too But then it is not Java
 
Guennadiy VANIN
Ranch Hand
Posts: 898
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot.
I am trying to get an overall picture, determine boundaries of SCWCD and JavaTechnologies, at large, and all Java Technology articles, books, et. al., leave me with difficulties even at introductory topics.
 
Guennadiy VANIN
Ranch Hand
Posts: 898
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take any book on CGI.
It tells that CGI application may be written in any language, including JAVA.
I just wonder who have invented all that advantages and shortcomings of CGI? and what is the difference of CGI and servlet
 
You ought to ventilate your mind and let the cobwebs out of it. Use this cup to catch the tiny ads:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic