Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
1.2 The Advantages of Servlets Over  Traditional  CGI
7
example, servlets could be embedded in mail or FTP servers to extend their
functionality. In practice, however, this use of servlets has not caught on, and
I'll only be discussing HTTP servlets.
1.2 The Advantages of Servlets 
Over  Traditional  CGI
Java servlets are more efficient, easier to use, more powerful, more portable,
safer, and cheaper than traditional CGI and many alternative CGI like tech 
nologies. 
Efficient
With traditional CGI, a new process is started for each HTTP request. If the
CGI program itself is relatively short, the overhead of starting the process can
dominate the execution time. With servlets, the Java Virtual Machine stays
running and handles each request using a lightweight Java thread, not a
heavyweight operating system process. Similarly, in traditional CGI, if there
are N simultaneous requests to the same CGI program, the code for the CGI
program is loaded into memory N times. With servlets, however, 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 per 
form other optimizations that rely on persistent data. Servlets, however,
remain in memory even after they complete a response, so it is straightfor 
ward to store arbitrarily complex data between requests.
Convenient
Servlets have an extensive infrastructure for automatically parsing and decod 
ing HTML form data, reading and setting HTTP headers, handling cookies,
tracking sessions, and many other such high level utilities. Besides, you already
know the Java programming language. Why learn Perl too? You're already con 
vinced that Java technology makes for more reliable and reusable code than
does C++. Why go back to C++ for server side programming? 
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved