Java Reference
In-Depth Information
After modifying the deployment descriptor, any servlet placed in the default
servlet folder can be located and executed by the Tomcat servlet container. JSPs
are placed in the root directory, as are any other Web pages.
Mapping Servlets in Deployment Descriptors
Traditionally, requests for servlets are mapped to servlet/* so that
any URL requesting a servlet simply precedes the servlet name
with servlet/. Patterns other than servlet/* can be used; this
pattern is simply customary.
Enabling Servlet Reloading for Tomcat
As indicated earlier, once a servlet is loaded, it remains loaded in the Web
server process and available for use by subsequent requests. If the servlet class
file is changed, for example, after making a change to the source code and
recompiling, the original version still remains loaded in the Web server process.
This means that subsequent requests do not use the new servlet version but the
old version. To allow new requests to use the new servlet version, the Web server
must be stopped and restarted, which will cause the new servlet to be loaded
upon the next request for it. In a production environment, this may be
acceptable.
In a development environment, however, having to stop and restart the
Web server each time you update a servlet can be needlessly time-consuming.
It would be much better to have the Web server (actually, the servlet con-
tainer) recognize when the servlet has changed and automatically load the new
version — a process called
servlet reloading
. Servlet reloading is enabled in
Tomcat by making a small change to the Context file, context.xml, in the conf
folder (e.g., C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf).
The context information in this file is loaded by all web applications (webapps)
and is shown in Figure 12-80. This change is new with Tomcat 5, as earlier ver-
sions made a similar change directly to the server.xml file, which is no longer
recommended.
Search WWH ::
Custom Search