|
|
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 3 of 6
The most common way to generate HTML forms is through the Struts HTML tag library, which is not XML compliant and therefore unusable in conjunction with XSLT. Modifying the HTML tag library to output XHTML is easy, but it still changes the existing Struts 1.0 codebase.
Furthermore, the tag library solution requires programming in four separate places: the Action class (controller), the model beans, the JSP, and the XSLT stylesheet (view). This requirement creates a labor-intensive
solution. Additionally, the roles of the JSP and tag libraries are limited to converting the model beans into an XML document.
The second approach, which is our proposed Model 2X solution, automates this task, effectively removing JSPs from the equation. As Figure 2 illustrates, this design decision forms the heart of Model 2X.

Figure 2. Model 2X
As you can see in Figure 2, the first part of the Model 2X pipeline is the regular Struts pipeline. The request is sent to
the Struts controller servlet, then dispatched to the appropriate business logic, an Action subclass. The controller creates an ActionForm object; the object is filled with the appropriate request parameters. The Action subclass encapsulates the business logic, fills out the beans, and then forwards the beans to the view.
That is where the Model 2X pipeline differs from regular Struts: instead of a JSP implementing the view, a servlet, XSLServlet, now implements it with an XSLT stylesheet's help. This servlet first generates an XML document from the beans and context,
and calls the XSLT transformer. We detail this process below, which you can achieve without changing Struts because you can
forward a request to any URL in the Struts configuration.
The process of transforming an object into a stream is known as serialization. Since Java 1.1 introduced the java.io.Serializable interface and related APIs, Java developers have understood binary serialization well. Binary serialization transforms a
Java object into a binary stream that can be sent over the network or saved into a file. In contrast, XML serialization transforms
a Java object tree into a textual XML stream.
Many closed and open source software packages, such as Castor, perform XML serialization. For the Model 2X application, we
used a simple custom implementation. This simple implementation assumes that all bean properties are either primitive Java
types or java.util.Collection subclasses.
The custom implementation recursively introspects the form, request, and session beans, and creates a DOM (Document Object Model) tree. Concurrently, the implementation serializes the resources and Struts configuration data known as context information. Figure 3 illustrates this process.

Figure 3. XML/XSL workflow
The XML stream represents a translation of the model on which the XSLT stylesheet is applied. In the Model 2X application,
XSLT transformation is limited to a single stylesheet cached by XSLServlet and applied to the XML stream provided by the Struts pipeline. You can enhance this simple architecture to provide several
successive transformations or more advanced configurations as seen in the Apache Cocoon framework. An XML publishing framework,
Cocoon uses XML and XSLT to build server-side applications. Its pipeline-based architecture makes it easy to separate content
and logic, and to interact with many different data sources. XSLT allows Cocoon to adapt its output to different device capabilities
such as HTML, WAP (Wireless Application Protocol), and so on.