Edit Edit

Java Servlet FAQ


What are the benefits of servlets?


1) Servlets are portable. You can develop the servlet on one platform and deploy it on a different platform.

2) Servlets are simple to write. You have access to the entire family of Java APIs. In addition, you can use the cookie handling and session tracking classes.

3) Servlets are more efficient than CGI scripts. CGI scripts are typically written in Perl and whenever a request is made to the CGI script, a Perl interpreter needs to be spawned for each request. This is very expensive in terms of speed and memory resources. Servlets on the other hand are loaded once into memory and each request is handled by a separate thread Because a servlet stays in memory, it can maintain its state and hold onto resources, like database connections, that may take seconds to establish.

4) Servlets are safer than CGI scripts. CGI scripts written in C++ that mistakenly make invalid pointer references or divide by zero errors could cause the Web server to crash. Servlets that make the same errors would cause an exception to be thrown. The servlet engine would catch the exception and handle it gracefully.

5) Servlets can interact with the server by calling the server to translate file paths, output to the server’s log file, etc. CGI scripts are passed all the information it needs to process a request and then it is isolated from the server.

6) Servlets are server-independent and do not tie you into a proprietary API like the Netscape Server API.




Last updated 12/25/1999 05:22:32 PM