JSP and Servlets
Servlets are pieces of Java™ source code that add functionality
to a web server in a manner similar to the way applets add functionality to
a browser.
Servlets are designed to support a request/response computing
model that is commonly used in web servers. In a request/response model, a client
sends a request message to a server and the server responds by sending back
a reply message.
From the Java Servlet Development Kit (JSDK), you use the Java
Servlet API to create servlets for responding to requests from clients. These
servlets can do many tasks, like process HTML forms with a custom servlet or
manage middle-tier processing to connect to existing data sources behind a corporate
firewall. In addition, servlets can maintain services, like database sessions,
between requests to manage resources better than Common Gateway Interface (CGI)
technologies.
Tomcat
is the Reference Implementation for the Java Servlet 2.2 and JavaServer Pages
1.1 Technologies. Tomcat is the official reference implementation for these
complementary technologies.
Developed under the Apache license in an open and participatory
environment, Tomcat is intended to be a collaboration of the best-of-breed developers
from around the world. Sun will continue responsibility for the Servlet API
and JavaServer Pages specifications, which are being developed under the Java
Community Process.
Thread Pool of Connectors
Tomcat is configured to use a thread pool. Servlet containers
that are using a thread pool relieve themselves from directly managing their
threads. Instead of allocating new threads; whenever they need a thread they
ask for it from the pool, and when they are done, the thread is returned to
the pool. The thread pool can now be used to implement sophisticated thread
management techniques, such as:
. Keeping threads "open" and reusing them over and over again. This saves the
trouble associated with creating and destroying threads continuously.
. Setting an upper bound on the number of threads used concurrently. This prevents
the resources allocation problem associated with unlimited thread allocation.
If the container maxed out to the threads upper limit, and a new request arrives,
the new request will have to wait for some other (previous) request to finish
and free the thread used to service it.
Servlets are designed to work within a request/response
processing model. In a request/response model, a client sends a request message
to a server and the server responds by sending back a reply message. Requests
can come in the form of an HTTP URL, FTP, URL, or a custom protocol.