Servlet Implementation

We are almost finished! The remaining piece of the puzzle is to coordinate activity between the web browser, database, domain objects, JDOM producers, and XSLT stylesheets. This task lies in the servlet implementation and related classes. In an XSLT-driven web application, the servlet itself really does not do all that much. Instead, it acts as a mediator between all of the other actions taking place in the application.

Figure 7-9 shows the UML class diagram for the com.oreilly.forum.servlet package. This design consists of a few key classes along with numerous subclasses of Renderer and ReqHandler. These subclasses are very repetitive in nature, which is indicative of the highly structured application design that XML and XSLT facilitate.

Servlet design

Figure 7-9. Servlet design

A single-servlet design has been adopted for this application. In this approach, the ForumServlet intercepts all inbound requests from clients. The requests are then delegated to subclasses of ReqHandler, which handle requests for individual pages. Once the request has been processed, a subclass of Renderer selects the XML and XSLT stylesheet. XSLTRenderHelper does the actual XSLT transformation, sending the resulting XHTML back to the browser.

This is not designed to be a heavyweight web application framework. Instead, it is just a simple set of coding conventions and patterns that help keep the ...

Get Java and XSLT now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.