StrutsCX – Struts with XSLT

Bernhard Woehrlin


Table of Contents

1. StrutsCX - Struts with XSLT
2. The StrutsCXServlet
3. i18n - internationalization with StrutsCX
4. Error handling with StrutsCX

1. StrutsCX - Struts with XSLT

StrutsCX is a small Struts add-on framework that combines Struts with Castor XML and XSLT.

StrutsCX uses the Controller and the Model of Struts, but replaces the JavaServer Pages with XSLT.

The StrutsCX architecture

Picture 1: The StrutsCX architecture.

The diagram demonstrates the differences to Struts. The Controller and the Model components stay untouched. But in the View StrutsCX does not forward to a JavaServer Page but to a Servlet, which organizes the construction of a XML Document object as well as the transformation of this object with a XSL Stylesheet. Is an ActionForm Bean present, the Action copies the Bean to the HttpServletRequest and this is also added to the XML Document. Similar to Struts, the job of the Action is to mediate between the presentation tier and the other tiers of the J2EE architecture: the business- and integrations-tier.

StrutsCX behaves differently to Struts in the following aspects:

  • In the View StrutsCX uses XSLT instead of JSP.

  • Internationalization is not realized through the Java Resource Bundle technique but through a pure XML solution.

  • StrutsCX does not need any Tag Libraries to present error messages. Instead of this it uses W3C standards like XML and XSLT/XPath.

Despite these changes you can use StrutsCX in your existing Struts application without any trouble. This is because StrutsCX merely abandons some of the classical Struts features and replaces them with XML-, XSLT- and XPath.