Sourceforge Project Site

Configuring with Struts 1.0

A guide to stxx


Stxx works with Struts 1.0.x by sub-classing the ActionServlet class to insert the stxx processing instructions where they are needed. To facilitate this, changes to the web.xml file are required.

Since the ActionServlet class has been overridden by stxx, so the web.xml needs to point to the new implementation.


The factory attribute needs to point to the stxx application resources factory class. This is because stxx changes the way that application resources are used.


The forward attribute needs to point to the stxx implementation of the ActionForward class that supports transformations.


Once this has been configured, a parameter will need to be set which points to the stxx properties file where further configuration parameters can be set. This file is expected to be loaded from the classpath, so it must reside in /WEB-INF/classes to be found.

All web.xml init-params used by stxx
Name Value Status
action com.oroad.stxx.action.ActionServlet Required
factory com.oroad.stxx.util.PropertyMessageResourcesFactory Required
forward com.oroad.stxx.action.ActionForward Required
stxxInit / Required


The next change you need to make is to the struts-config.xml file. The changes here are to add a new tag called <transform> that nests underneath the <forward> tag. This tag allows you to add as many transformation possibilities as you need, but only one will be run for a particular forward.

The changes will look like this:

<action path="/contactListExample" 
    <forward name="success"> 
        <transform name="default" 
        <transform name="Mozilla" 
        <transform name="MSIE" 

The name attribute of the transform tag is the most important. It allows for stxx to choose the transformation to perform on the XML for a given criteria. By default, stxx will choose the transformation based on the type of browser the client is using.

In this case, the value of the name attribute maps to the list of defined user-agents in the file. A value of default is the value to be used if no match to the user-agents can be found.

For example, you could put the name "Mozilla" in the user-agent property and assign various Mozilla user-agents strings as the value, then stxx will try to match the user agent of the client to whatever is in the Mozilla property. For more information, please check out the section Configuring

The path defines the location that stxx can find the XSL file to transform the XML into HTML. The path is referenced from the root of the web application, for example "/foo.xsl" will match to the URL

The "type" attribute is the key that tells stxx which transformation process to use. By default, it is set to 'html.' This tells stxx that the XML you create should be transformed with the 'html' transformer, which is usually configured to combined the XML with the XSL template you specify and output HTML as it is in this example. Stxx supports transformation types that use XSL-FO (for PDF's, SVG's, RTF's, etc), Cocoon, Velocity, XMLForm, and of course XSL transformations for any text-based output type.

All struts-config.xml attributes used by the stxx transform tag
Attribute Value Status
name The name of the selector Required
path The path to the XSL file Required
render client | server (default) Optional
debug true | false (default) Optional
type Which transformer to use, html is the default Optional

The same transform tag also works within the global-forwards tag.

by Don Brown