Introducing eXtensible Server Pages, XSP
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
Dr. Bill Brogden is my company's lead programmer and the author of numerous books on Java, including a couple of recent titles that have focused on server-side Java and XML. More particularly, one of his recent titles for Sybex--Java Developer's Guide to Servlets and JSP--addresses the ins and outs of working with Java Server Pages to build powerful, interactive Web sites. That's why I was particularly interested to learn, from Bill, about a new technology that's emerging from the Apache Cocoon project: It's called XSP, and attempts to do for JSP what XML did for HTML--namely, to create a way of building server-side functionality that separates syntax and semantics from content, and allows content and online interactivity to be managed explicitly and abstractly.
In many ways, the parallels between HTML and JSP are striking: although it's possible through clean, well-thought-out designs to use parameters and variables to deliver dynamic content into Java Server Pages, because JSP pages include a mix of static HTML or XML markup, JSP tags, and bits of Java code called "scriptlets," it's also easy for programmers to embed such information directly into such executable images. This makes it far too easy to entangle content, structure, and behavior into a spaghetti-like mishmash. In the same vein, HTML gives page designers the opportunity to intermingle content with presentation in ways that make it hard to maintain the two separately as documents change and grow over time. You might be tempted to reply that Dynamic HTML is more analogous to JSP, but the advantage of servlets and server pages in general is that they can perform processing in a controlled environment, and deliver only browser-neutral HTML or XHTML to end users, thereby sidestepping many of the thorniest issues that have made Dynamic HTML such a tar baby for so many Web developers.
In a nutshell, XSP takes the Cocoon concepts of a "producer" and "processor," and applies those concepts to the creation of dynamic content. In this context, a producer is a Cocoon Java type that creates XML content at the mouth of a Cocoon processing pipeline. A processor combines a document object model (DOM) version of an XML document with a series of operations or transformations of the model's content or structure, and usually produces another DOM version as its output. Because one Cocoon processors can feed another, the analogy to a piped series of filters or processes is quite fitting.
To begin with, XSP pages must be compiled into Cocoon producers--that is, they provide the starting point for creating XML content and for intermingling static and dynamic elements. So where JSP creates servlets, XSP generates producers. But instead of resulting directly in executable document handling entities, XSP can then link to one or more processors that operate on XML content within the context of a DOM tree. XSP also includes support for an explicit stack to manage how elements nest inside the DOM, a parser that can create new DOM trees to parse external XML documents, plus a number of basic utilities that can manipulate document contents, create or manage markup, work with forms, and manipulate numerous kinds of text values. In short, XSP makes it easy for developers to tackle the same kinds of functionality they might tackle with JSP within a cleaner, more maintainable development framework.
The goals of the Cocoon project are to explicitly separate and address issues related to document content, style, and logic explicitly by separating such data into distinct XML files. These separate domains may then be merged at run-time using XML transforms to bring them together. Because they represent distinct activities usually undertaken by different individuals or groups, the hope is that Cocoon will help to define a more effective way to manage and deliver content in whatever form it's needed. Thus, it should come as no surprise that XSP represents that part of the Cocoon project designed to deal with dynamic or interactive content matters.
Send an e-mail to Ed at firstname.lastname@example.org if you have questions on this or other XML topics. Cocoon remains an emerging technology, rather than a finished product, but it's worth investigating nevertheless. For a more detailed treatment of XSP, see Sue Spielman's story for XML.com (http://www.onjava.com/pub/a/onjava/2001/02/22/jsp_servlets.html). For more information about the Cocoon project, please visit http://xml.apache.org/cocoon/index.html.
Ed Tittel is a principal at LANWrights, Inc., a wholly owned subsidiary of LeapIt.com. LANWrights offers training, writing, and consulting services on Internet, networking, and Web topics (including XML and XHTML), plus various IT certifications (Microsoft, Sun/Java, and Prosoft/CIW).
Did you like this tip? If so, why not let us know? Email to sound off, or to submit a tip of your own.