Building a Custom Web Server

You may want to add additional features to the web server with your own servlets. This document discusses how to do this.

The build process relies on the Ant build tool from The Jakarta Project. A build.xml file is included, and the only file you need to modify for your own configuration is the build.properties file.

Subject Menu


Including Your Own Source

The build process allows you to include your own source. You will need to modify at least two build properties: src.paths, src.files, and possibly dependency.classpath.

Place the location of the source files in src.paths, and a list of files in src.files. If your code depends on further libraries, you may need to modify dependency.classpath as well. See the build configuration section for more details.

[Top]


Including Your Own Classes

It is also possible to include your own pre-built classes in the build process. To do this, add the location of the classes to dependency.classpath.

[Top]


Build Configuration — The build.properties File

The build.properties file is the only place you are required to manage your build configuration. The syntax requrements are only that a forward slash (/) for the file separator, and a colon (:) for the path separator, are used. Also, any non-required properties may be left unspecified.

Note: If you choose to use backslashes (\) for your paths, say, in Windows, then you must use pairs (eg. src.paths=C:\\Projects\\MySource). This is because in properties files, backslashes are treated specially. They act to change the meaning of the following character. Please consult the Java documentation for more information.

cdc.classes

This property should point to the core CDC classes for your environment. Leave it unspecified to use the default JDK classes.

src.paths

This points to the location(s) of your source files. For example:

src.paths=mysrc:myservlets/src

A path separator is used between different paths.

src.files

A comma- or space-separated list of source files. This may be specified using Ant-style wildcard patterns. For example:

src.files=com/mycompany/util/*.java,com/theircompany/**/*.java

It is not a good idea to specify **/*.java since that may include unwanted source files. Instead, be more specific with the package structure, as in the above example.

dependency.classpath

This specifies a CLASSPATH-like list of paths and archives containing any classes needed by your source files. For example:

dependency.classpath=mymodules.jar

target.jar

This names the JAR file that will be created from any compiled source code that was specified with src.files. If not specified, then the default will be "myclasses.jar".

This should not contain extra path information. For example:

target.jar=mylib.jar

These are incorrect: target.jar=path/mylib.jar or target.jar=/root/path/mylib.jar.

This file will be included by the deploy script.

One additional step you must do is prepend this file to the '-classpath' setting inside the WebServer script in the bin/ directory. This will enable the virtual machine to find your classes.

[Top]


Other Build-Related Files

This section discusses the other files needed in the build process.

The build.xml file

The build.xml file is the Ant build script. Its default task will automatically compile your source files and archive them into a JAR file in the bin/ directory.

By default, all compiled classes will be written to a directory named classes/. This can be changed by changing the javac.destination property to something else.

[Top]