Java Reference
In-Depth Information
G ETTING S TARTED WITH S ERVLETS AND JSP S
If you choose to install the Tomcat Web server bundled with the CD-ROM that ac-
companies this topic, you already have a complete environment for testing servlets
and JSPs. Tomcat, the servlet engine from the Apache Project, is also integrated
with Eclipse; you can actually debug your servlets from inside the Eclipse IDE.
Or, you can download Tomcat from the Apache Web site ( http://
tomcat.apache.org/) and install it. For this exercise, you can assume that Tomcat is
installed in C:\apache-tomcat. If you have installed Tomcat in some other direc-
tory, then substitute your directory in place of apache-tomcat.
Once you install Tomcat and start it, you will need to place your compiled
servlet class files and JSPs in the proper directories for them to be recognized by the
servlet engine. For this exercise, you will copy the compiled class file to the exam-
ples directory (C:\apache-tomcat\webapps\examples\servlets).
Follow the instructions in the installation and configuration information on how
to invoke your servlet or JSP. In particular, you will need to make sure that there is a
JAVA_HOME environment variable that points to the location where you have the
JDK installed. On most Windows systems, this means you will have to use the path
Computer > Properties > Environment Variables to set a new environment variable.
On Windows Vista, the path is Computer > Properties > Advanced Properties > En-
vironment Variables. Select the option to add a new environment variable. Name the
variable “JAVA_HOME,” and set the value to the location of the Java SDK (C:\Pro-
gra~1\Java\jdk1.6.0_03). Click the OK buttons until this change is accepted.
Double-clicking on (running) the startup.bat file in the apache-tomcat\bin di-
rectory should now start Tomcat. If Tomcat does not start, visit the Tomcat FAQ
pages at tomcat.apache.org. You can stop Tomcat by running the shutdown.bat file.
You will need to specify a port number if the servlet engine is not running on
port 80. For example, invoking myjsppage.jsp if the servlet engine is running on
port 8080 might require you to enter an address like this into your browser:
ON THE DVD
http://localhost:8080/myjsppage.jsp
Search WWH ::




Custom Search