Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
24
Chapter 2 First Servlets
Compiling and Installing the Servlet
The first thing you need to do is to make sure that your server is configured
properly and that your
CLASSPATH
refers to the JAR files containing the stan
dard servlet classes. Please refer to Section 1.5 (Installation and Setup) for an
explanation of this process.
The next step is to decide where to put the servlet classes. This location
varies from server to server, so refer to your Web server documentation for
definitive directions. However, there are some moderately common conven
tions. Most servers have three distinct locations for servlet classes, as detailed
below.
1. A directory for frequently changing servlet classes.
Servlets in this directory are automatically reloaded when
utorial/
their class file changes, so you should use this directory during
vailble at cat T
development. For example, this is normally
om
install_dir/servlets
with Sun's Java Web Server and
IBM's WebSphere and
install_dir/myserver/servlet
omcat are a
classes
for BEA WebLogic, although most servers let the
or T /Apache Tm
server administrator specify a different location. Neither
Tomcat nor the JSWDK support automatic servlet reloading.
ons f
Nevertheless, they still have a similar directory in which to
recti
place servlets; you just have to stop and restart the mini server
each time you change an existing servlet. With Tomcat 3.0,
.coreservlets.co
place servlets in
install_dir/webpages/WEB INF/classes
.
w
With the JSWDK 1.0.1, use
TE: Updated di
install_dir/webpages/WEB INF/servlets
.
NO http://ww
2. A directory for infrequently changing servlet classes.
Servlets placed in this location are slightly more efficient since
the server doesn't have to keep checking their modification
dates. However, changes to class files in this directory require
you to restart the server. This option (or Option 3 below) is the
one to use for production servlets deployed to a high volume
site. This directory is usually something like
install_dir/classes
, which is the default name with Tom
cat, the JSWDK, and the Java Web Server. Since Tomcat and
the JSWDK do not support automatic servlet reloading, this
directory works the same as the one described in Option 1, so
most developers stick with that previous option.
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved