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"?
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
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
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.
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
A "dutch baby" is not a baby. But this tiny ad is baby sized:
Free, earth friendly heat - from the CodeRanch trailboss