The JSP Standard Tag Library

The Freemarker templating system used by Titania Delivery is a Java library. As such, Java Server Pages tags can be used inside Freemarker templates.

Include JSP tag libraries by #assigning them to a variable. For example:

<#assign c=JspTaglibs['http://java.sun.com/jsp/jstl/core']/>

The Titania Tag Library is a JSP tag library, so it can be included in the same way.

Once assigned to a variable, the tag libraries can be utilized using dot syntax. For example, given the <#assign> statement above, one could write:

<@c.if test="${foo}">
 Do this
</@c.if>
Note: Many functions made available by the JSP Standard Tag Library are included natively in Freemarker. It is up to the Portal Theme developer to decide which API they prefer to use. Titania recommends using the Freemarker constructs where possible and practical.

Standard XML Tag Library

Freemarker has some ability to handle XML node-valued variables in the data model, but no native ability to generate XML nodes in a template. To do that, use the JSP xml tag library. This library is old and unmaintained, but can work for limited uses.

See the "XML Tag Library" topic in "The Java EE 5 Tutorial" for documentation.

Include the tag library by assigning to a variable.

<#assign x=JspTaglibs['http://java.sun.com/jsp/jstl/xml']/>

Parse an XML string into a Freemarker node variable.

<#assign xmlString = '<doc>text</doc>'/>
<@x.parse var="xmlDoc" doc=xmlString/>
<#-- now process variable 'xmlDoc' using jsp or freemarker -->

See the Freemarker XML Processing Guide for general information on XML processing in Freemarker templates.

If the XML content uses namespaces, it might be helpful to set namespace prefixes for the template. Refer to the #ftl directive documentation for the ns_prefixes parameter. Among other things, this will declutter serialized output from Freemarker xml builtins.

Note: The xml taglib <@x.parse> directive does not always use the namespace prefixes defined in the Freemarker ns_prefixes hash. If you have any problem processing namespaced XML from <@x.parse> in Freemarker, check the markup to see what namespace prefixes are used. If you do not need namespaces for processing, it might be easiest to remove namespace declarations from the input string before calling <@x.parse>.