Notes on problems with Tomcat chapter 3 examples

The code sample I worked up with Tomcat 3.1 does not work right with at least one version of Tomcat 3.2. The Tomcat version I had a problem with is dated: 12/12/2000 as are the jaxp.jar, and parser.jar files.

I am accessing Tomcat as http://localhost:8080/

The tomcat/conf/server.xml file has the following lines to establish the XMLbook context.

<Context path="/XMLbook" docBase="webapps/XMLbook" debug="0" reloadable="true" > 

The directory setup is:

      with subdirectories as Chap03 etc 

In the WEB-INF directory I have a web.xml file that has the following entry for the cattest servlet:


Note that this defines the directory for the catalog files as:


   catalog.css catalog.dtd and catalog.xml are stored there.

   contains the .gif files that match the various entries
   (note that this includes book "cover" files in)

In the WEB-INF\classes\com\XmlEcomBook\catalog directory I have


In the Chap03 directory I have only CatTest.html as follows:

<body><font size="4">
<center><h2>Experiment With Catalog Presentation</h2>
XMLgifts goodies<br>
<form method="POST" action="http://localhost:8080/XMLbook/servlet/cattest" >
<input type="hidden" name="select" value="all" >
<input type="hidden" name="action" value="showcatalog" >
<input type="submit" value="Start" ><br>
<form method="POST" action="http://localhost:8080/XMLbook/servlet/cattest" >
<input type="hidden" name="action" value="selectkeyword" >
<input type="submit" value="Start Keyword" ><br>



When testing this setup with the original catalog.xml, which starts with a DTD reference as follows:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE catalog SYSTEM "catalog.dtd">

I got the following error shown in the Tomcat console window:

CatalogTestServ init called
setTheCatalog with c:\tomcat\webapps\XMLbook\catalog\catalog.xml
org.xml.sax.SAXParseException: Relative URI "catalog.dtd"; can not be 
resolved without a document URI.
  Line number: 2
Column number: -1
 Public ID: null
 System ID: null
CatalogTestServ init java.lang.NullPointerException
Tomcat 3.1 didn't have any problem with this configuration because the parser looked for the DTD in the same location as the catalog.xml file. I am still trying to figure out exactly what this version of the parser wants here.


I changed catalog.xml to avoid requiring the DTD and it worked. The start of the catalog.xml file now reads:

<?xml version="1.0" standalone="yes"?>

In c:\tomcat\bin directory, executing startup.bat shows:

Using CLASSPATH: C:\tomcat\classes;C:\tomcat\lib\ant.jar;

Tomcat window includes the following line:

2001-03-08 11:29:48 - ContextManager: Adding context Ctx( /XMLbook )   

Addressing the test page:

  the Start button  shows the full catalog as expected.
  the Select keyword shows the list of keywords as expected.

Note that this is all the initial CatalogTestServ is expected to do, more functions are added in the next chapter.