Client-Side Presentation Logic
617
Compiling the Servlet
In order to compile the VacationServlet, you must make sure you have xerces.jar; it should go
without saying that you will need the servlet API jar file in your classpath. First, open a Command
Prompt window and change your working directory to the\vacserv\web-inf\classes\ directory.
You should able to compile the servlet using the following line:
javac -classpath .;<path_to>\xerces.jar VacationServlet.java
On my system <path_to> equates to c:\Xerces\Xerces.jar
Setting Up Tomcat 3.2.1
Place the files generated in the webapps\ directory for Tomcat. The complete web application looks
like this:
webapps\
vacserv\
aelfred.jar
DealsParser.class
index.html
TravelDeal.class
VacationApplet.class
WEB-INF\
web.xml
classes\
VacationServlet.class
com\
wrox\
pjxml\
DealsFinder.class
DOMBuild.class
DOMWriter.class
queryBean.class
sqlBean.class
That means both the client and server are being served from the same web application in Tomcat. There is
one file that is left for us to write, the web.xml descriptor file that will contain the servlet mapping:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>
locatedeals
</servlet-name>
<servlet-class>
VacationServlet
</servlet-class>
</servlet>
</web-app>
We are assuming that you have modified tomcat.bat to include xerces.jar as the first entry in
Tomcat's classpath.