The ServletDispatch class is a utility class for building Servlets that navigate over trees of objects, but can also be used for writing simple Servlets (for example, by extending the com.mortbay.Servlets.DispatchServlet class). It provides methods for dispatching a servlet request over an object and calling a method on that object according to the pathInfo. Successive segments of the pathInfo can be used to navigate deeper into a tree. It also allows easy decoding of request parameters and conversion to native types.
An example of how this can be used to make coding servlets easier is the Property Tree Editor. This constructs a tree of HTTP handling nodes to handle editing of nodes within a property tree and allows values to be add, removed and the properties file to be loaded or saved.
The source code for the PropertyTreeEditor is included below.
PropertyTreeEditor.java |
---|
|