Servlets Replace CGI Programs Servlet technology was developed to improve upon and replace CGI programs. Servlet technology is superior to CGI but uses the same HTML code. So you can switch from CGI programs to servlets on the back-end without having to change the programming on the front-end. Servlets use the CGI protocol. In addition to Java technology's platform independence and promise of write once, run anywhere, servlets have other advantages over CGI programs: • Servlets are persistent. They are loaded only once by the Web server and can maintain services such as database connections between requests. • Servlets are fast. They need to be loaded only once by the Web server. They handle concurrent requests on multiple threads rather than in multiple processes. Thus, applications with servlets perform better and are more scalable than the same applications using CGI programs. • Servlets are platform and Web server independent. • Servlets can be used with a variety of clients, not just Web browsers. • Servlets can be used with a variety of client-side and server-side Web programming techniques and languages. One of the most remarkable differences between servlets and CGI programs is that Web servers automatically maintain user session state for servlets. This means that the servlet can store user-session specific information in a user session object and retrieve that information on a subsequent call. The isCOBOL Runtime Framework uses this feature to associate the user session with a COBOL thread context. This makes sure that the same instances of COBOL programs get used each time they are called during a particular user session. In other words, COBOL programs called during a particular user session retain their file states and working-storage data between requests from that user session. If desired, the programmer can cancel the program at any time with the CANCEL statement. In fact, at first it will be necessary to cancel old CGI programs because they were written to assume that they have been cancelled between calls. Later, the CANCEL statement can be removed as the old CGI programs are updated to make use of the stateful nature of servlets.