Moving from CGI to Servlets

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 ...

Get MySQL™ and JSP™ Web Applications: Data-Driven Programming Using Tomcat and MySQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.