Building A Servlet of Your Own

Once you have a bunch of RefEntry documents you are happy with, you can build your own servlet containing them. The servlet content comes with an Ant build file for generating your own servlet.

Before generating the servlet, you must install both Ant, which can be installed with the project software, and JUnit, which is installed when you install the HttpUnit pack with the project software. Ant is indispensable; JUnit is strongly recommended. If you choose not to install the HttpUnit pack, which contains the JUnit framework and other software used for functional unit testing, resist the temptation to hack at any of the Java code, and edit the build file, build.xml, to remove dependencies on the accept target.

To Adjust The List of RefEntry Documents

Follow these steps:

  1. Change to the src/conf/ directory where you unpacked the servlet content.

  2. Edit the refentrys.props Java properties file in which each line is of the form:

    refentryID=/path/to/refentry.xml

    Here, refentryID must be equivalent to refentrytitle-manvolnum for the servlet to work.

(Optional) To Change The List of Words to Ignore

Follow these steps:

  1. Change to the src/conf/ directory where you unpacked the servlet content.

  2. Edit the cw.props Java properties file such that the CommonWords property includes a list of the words to ignore when indexing RefEntry documents in the servlet and when handling searches from client browsers.

(Optional) To Modify Stylesheet Formatting

Follow these steps:

  1. Change to the src/xslt/ directory where you unpacked the servlet content.

  2. Edit only refentry.xslt.

    refentry.xslt changes the layout of the resulting XHTML document, but does not affect how the servlet itself functions. Other XSLT files in the directory are used by the servlet, so modify them at your peril.

    For example, you may add a ManVolNum section title, by adding and xsl:when element similar to the existing elements under the xsl:variable element near the top of the file.

To Build Your Servlet

Follow these steps:

  1. Ensure Ant and JUnit are installed.

  2. Change to the directory where you unpacked the servlet content.

  3. (Optional) If you did not install JUnit, edit build.xml to remove accept from the list of dependencies for the war target.

  4. Run ant.

    For example:

    $ ant
    Buildfile: build.xml
    
    init:
        [mkdir] Created dir: /home/mcraig/refentry/build
        [mkdir] Created dir: /home/mcraig/refentry/build/build
        [mkdir] Created dir: /home/mcraig/refentry/build/classes
        [mkdir] Created dir: /home/mcraig/refentry/build/copy
        [mkdir] Created dir: /home/mcraig/refentry/build/docs
        [mkdir] Created dir: /home/mcraig/refentry/build/docs/api
        [mkdir] Created dir: /home/mcraig/refentry/build/serial
    
    compile:
        [javac] Compiling 20 source files to /home/mcraig/refentry/build/classes
    
    accept:
         [java] ......
         [java] Time: 9.064
    
         [java] OK (6 tests)
    
    
    servletunit:
        [javac] Compiling 4 source files
    
    tool:
        [javac] Compiling 1 source file
    
    copy:
         [copy] Copying 1 file to /home/mcraig/refentry/build/build
         [copy] Copying 1 file to /home/mcraig/refentry/build/build
         [copy] Copying 1 file to /home/mcraig/refentry/build/build
         [copy] Copying 1 file to /home/mcraig/refentry/build/build
         [copy] Copying 1 file to /home/mcraig/refentry/build/build
         [copy] Copying 1 file to /home/mcraig/refentry/build/build
         [copy] Copying 1 file to /home/mcraig/refentry/build/build
         [copy] Copying 1 file to /home/mcraig/refentry/build/build
         [copy] Copying 1 file to /home/mcraig/refentry/build/build
         [copy] Copying 1 file to /home/mcraig/refentry/build/build
         [copy] Copying 1 file to /home/mcraig/refentry/build/build
         [copy] Copying 1 file to /home/mcraig/refentry/build/build
         [copy] Copying 1 file to /home/mcraig/refentry/build/build
         [copy] Copying 1 file to /home/mcraig/refentry/build/build
         [copy] Copying 142 files to /home/mcraig/refentry/build/copy
    
    javadoc:
      [javadoc] Generating Javadoc
      [javadoc] Javadoc execution
      [javadoc] Loading source files for package org.mcraig.cs445.refentry...
      [javadoc] Constructing Javadoc information...
      [javadoc] Standard Doclet version 1.4.1
    
      [javadoc] Building tree for all the packages and classes...
      [javadoc] Building index for all the packages and classes...
      [javadoc] Building index for all classes...
    
    serialize:
    
    war:
          [war] Building war: /home/mcraig/refentry/dist/refentry.war
    
    BUILD SUCCESSFUL
    Total time: 1 minute 41 seconds

    This step may take a couple of minutes while the RefEntry documents are serialized.

  5. (Optional) Use the clean target to delete generated files.

    $ ant clean

For a full list of targets, read the build.xml file.