Professional Documents
Culture Documents
Servlets are used primarily with web servers, where they provide a
Java-based replacement for CGI scripts. They can be used to provide
dynamic web content like CGI scripts.
Advantages of servlets over CGI scripts:
1.
Servlets are persistent between invocations, which dramatically
improves performance relative to CGI programs.
2.
Servlets are portable among operating systems and among
servers.
3.
Servlets have access to all the APIs of the Java platform (e.g. a
servlet can interact with a database using JDBC API).
Servlets are a natural fit if you are using the web for enterprise
computing. Web browsers then function as universally available thin
clients; the web server becomes middleware responsible for running
applications for these clients.
Thus the user makes a request of the web server, the server invokes a servlet
designed to handle the request, and the result is returned to the user in the web
browser. The servlet can use JNDI, Java IDL, JDBC, and other enterprise APIs to
perform whatever task is necessary to fulfill the request.