Moving from CGI to Servlets

I l @ ve RuBoard

Servlets represented the second step that Java-enabled Web servers took away from the old CGI paradigm. In CGI-based Web programming, the CGI program was an external program run by the server. It took input from environment variables and the standard input stream, and it sent its response back via standard output.

CGI-based designs worked well for quite a long time, but they had a number of problems. For one thing, a significant processing cost was associated with spawning a new process each time a CGI request came in. In addition, it was extremely difficult to carry persistent data around because each process started fresh.

The first step was to allow designers to link their own libraries into the running server binary (under Netscape, this was called NSAPI, for example). This not only drastically increased performance, but it also allowed the code to gain access to internal server functionality.

Java servlets were developed to provide the best of both worlds . Because the Java servlet runtime was persistent and lived close to the Web server, it could interact with Web requests at a detailed level. But because it was Java, it was easy to firewall potential crashes off the server itself by catching exceptions at the top level of the servlet loop.

Also, because the servlet classes are standard, servlet code will run without modification (usually) on any Java-enabled Web server.

I l @ ve RuBoard


MySQL and JSP Web Applications. Data-Driven Programming Using Tomcat and MySQL
MySQL and JSP Web Applications: Data-Driven Programming Using Tomcat and MySQL
ISBN: 0672323095
EAN: 2147483647
Year: 2002
Pages: 203
Authors: James Turner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net