ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Pages: 1, 2, 3

Core tags

Each of the technologies has a set of core tags that are used throughout.

The XSP tag set consists of the following core tags.


Root of all XSP pages and specifies the scripting language and the tag libraries used by a particular XSP page


Top-level element encloses source program-level declarations such as <xsp:include>. This element is used to import external module definitions in a language-dependent way


Embeds procedural logic in an XSP page. Enclosed code is transcribed verbatim into the generated XSPPage producer. Other XSP or user markup may be nested inside this tag.


Embeds "regular" XML content inside an <xsp:logic> block so that no nested additional <xsp:logic> sections are required


Inlines a program expression as a Text node, except when used directly inside another <xsp:> element, where it is substituted as an expression, not a node. If you want to substitute an <xsp:expr> tag as a node inside another XSP tag, you must enclose it in an <xsp:content> element.


Dynamically builds an element when its attribute values are not known at compile time.


Dynamically provides attribute values for a given element (which can be specified statically as markup or dynamically by means of <xsp:element>). It's typically used in conjunction with <xsp:expr>, where the substituted expression is always cast to String


Dynamically creates a processing instruction


Dynamically creates an XML comment

The JSP Reference syntax can be found on Sun's Java site.

Which Technology is Right for Me?

So which technology is best for your project? The answer: it depends. There are pros and cons to both as we've seen, but each should be weighed according to your project needs.

If you are looking for a solution that maximizes reusable code across applications, then XSP is probably your answer. XSP allows the separation of content from presentation. This separation allows developers to handle content generation. The XSP page can be generated from a servlet or other Java code as well as being static. XML and XSL authors can handle presentation and styling through modification of the XSL stylesheet applied to the XSP page. Just as easily, XSP solves the other significant deficiency of JSP. Because XSP processing occurs before any stylesheets are applied, the resultant XML document can be transformed into any other format. This maintains all the advantages of XML. The XSP page can be transferred between applications as well as being used just for presentation.

If you want to keep your development teams clearly defined, then, again, XSP is probably your answer. The introduction of the JSP environment made significant improvements in dynamic web application development by better separating the application developer from the presentation designers. However it still involves a fair amount of interaction between the two. There is frequently a need for inline Java code to determine the correct presentation necessary when dealing with dynamic content. Custom tag libraries have helped address this and require the presentation person to be less knowledgeable about what the logic is actually doing. But that person still needs to understand how to use the tag library, which is usually more then a presentation person wants or needs to know.

XSP and accompanying framework focuses XSL and XSLT stylesheets for the presentation layer written by presentation designers, XML for the content provided by the content authors, and application logic layer and tagset generated by the application developer. The interaction of the technologies in the Cocoon framework is what glues everything together and allows XSL plus XML plus embedded tags to generate an HTML document. The tasks themselves are clearly separated.

If your main concern is getting a product out the door with the least risk factor, then JSP is your answer. JSPs are popular and widely understood, while XSP and Cocoon are still emerging. This is not something to overlook. For large scale projects, it is always necessary to evaluate how much effort it would take to bring a new developer up to speed and the pool of talent you can draw from. In addition, existing HTML and XML tools can be used for JSP development, making the overall time it takes to get rolling relatively short.

Sue Spielman is an associate editor for ONJava.com, covering JSP and Servlets technologies. She is also President and Senior Consulting Engineer for Switchback Software LLC.

Return to ONJava.com.