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" > 
</Context> 

The directory setup is:

c:\tomcat\webapps\XMLbook\
      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:

    <servlet><servlet-name>cattest</servlet-name>
       <servlet-class>com.XmlEcomBook.catalog.CatalogTestServ</servlet-class>
         <init-param>
            <param-name>workdir</param-name>
            <param-value>c:\tomcat\webapps\XMLbook\catalog</param-value>
         </init-param>
    </servlet>

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

c:\tomcat\webapps\XMLbook\catalog

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

c:\tomcat\webapps\XMLbook\catalog\images
   contains the .gif files that match the various entries
   (note that this includes book "cover" files in)
c:\tomcat\webapps\XMLbook\catalog\images\covers

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

  CatalogBean.class                
  CatalogTestServ.class            
  ProductFormatter.class           
  TheCatalog.class                 

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

<html><head>
<title>LANWrights</title>
</head>
<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>
<form method="POST" action="http://localhost:8080/XMLbook/servlet/cattest" >
<input type="hidden" name="action" value="selectkeyword" >
<input type="submit" value="Start Keyword" ><br>
</form></center>

<hr></body></html>

PROBLEMS

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.

FIX

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"?>
<catalog>

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

Using CLASSPATH: C:\tomcat\classes;C:\tomcat\lib\ant.jar;
   C:\tomcat\lib\servlet.jar;C:\tomcat\lib\webserver.jar;
   C:\tomcat\lib\jasper.jar;C:\tomcat\lib\jaxp.jar;
   C:\tomcat\lib\parser.jar;D:\JDK1.2\lib\tools.jar

Tomcat window includes the following line:

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

Addressing the test page:

http://localhost:8080/XMLbook/Chap03/CatTest.html
  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.