About us
Contact us
Products
Services
Articles
 Twitter    Bookmark and Share

XML Output JSP Actions - Overview

JSP Tag Library for Generating XML Dynamically

Devsphere has designed the XML JSP Tag Library (XJTL) for building Java XML-driven Web Applications together with the JSP Standard Tag Library (JSTL). XJTL provides specialized actions for XML output (<o:document>, <o:element>, <o:data>, <o:comment>, <o:pi>, etc) while JSTL has general output actions (<c:out> and <x:out>). Both XJTL and JSTL escape the character data, i.e. they replace &, <, > and " with &amp;, &lt;, &gt; and &quot;. However, XJTL knows when to disable the escaping (e.g. in CDATA sections and XML comments) while in the case of JSTL the escaping has to be disabled explicitly.

DOM serialization is an important output feature that is missing from JSTL and is offered by XJTL. You can take a DOM tree and output it as XML using the <o:document> XJTL action. XJTL also provides actions for processing SAX events and mixing DOM with SAX to achieve better parsing scalability. JSTL has additional actions for DOM parsing, DOM querying via XPath, XML flow control, XML transforming and other actions unrelated to XML.

XJTL is very good at generating XML dynamically because its actions do not interfere with the XML syntax. Many times, the name of an element or the values of its attributes are computed at runtime. With JSTL, you would have to include <c:out> actions between < and > and within the quotes of the XML attributes. To avoid such messy constructs, you can use the <o:element> and <o:attributes> XJTL actions. XJTL also generates the start and end of the XML comments, CDATA sections and processing instructions. These features make the JSP code very clean. See examples.

The Devsphere Java XML Projects download includes a code generator that takes an XML sample and produces a JSP page that outputs the given XML document using the JSP actions provided by XJTL.

XJTL needs JSP 1.2+ and uses the expression language introduced by JSTL that is now part of JSP 2.0.


Copyright © 2000-2009 Devsphere

About us
Contact us
Products
Services
Articles