Skip to content
OpenCms documentation
OpenCms documentation

The OpenCms taglib

OpenCms ships with its own <cms:*> taglib. It allows to invoke OpenCms functionality from JSPs. Whenever you write a template or a formatter, you will use tags from the OpenCms taglib. Here's how to use the taglib and a brief overview on the available tags.

To use the OpenCms taglib, insert the taglib directive in your JSP. This can be done in two different ways:

  1. With the standard JSP-/Servlet-technology (recommended):
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>

This directive must be set before any cms tags are used.

  1. With OpenCms specific short form:
<%@page buffer="none" session="false" taglibs="c,cms" %>
The standard way is recommended since with the short form, autocompletion in an IDE is not supported.

The following list of <cms:>-tags is available in the OpenCms standard taglib. A tag can be executed by calling:

<cms:tagName attributes...></cms:tagName>

Loads a resource bundle to be used by its tag body. The tag is similar to <fmt:bundle>, but able to handle OpenCms XML-bundles.

Enables the template mechanism for container pages.

Provides access to the content for the JSP EL.

Provides conditional logic for checking the element of a XML content.

Provides access to the result set of a contentload.

Loads XML content items from the OpenCms VFS.

Allows looping through XML content node element values.

Provides access to individual XML content node element values.

Provides decoration of HTML content.

Provides different HTML output for various device types.

Enables direct editing within a template.

Provides access to the settings of an ADE container element.

Enables advanced direct editing within a template.

Writes JSP code from a JSP to files in the static export.

Loads single XML content items for ADE formatters.

Includes required CSS or Javascript resources, placed in html/head.

Supports image scaling using the OpenCms native image scaling mechanism.

Includes other JSP elements dynamically at runtime.

Enables access to some system information like OpenCms version etc.

Allows inclusion of jQuery, some jQuery plugins code and stylesheets.

Reads localized values from resource bundles (Java property files like workplace.properties) that hold user messages.

Builds a valid OpenCms URL for a given resource.

Provides access to the navigation information.

Sends no-cache headers to the browser.

Adds a parameter to the outer tag (if supported).

Decorates HTML with custom A_CmsConfiguredHtmlParser implementations given in the parserClass attribute.

This tag is used to generate a link to a PDF generated from XML content given the path of the XML content.

This tag is used to generate a link to a thumbnail for a PDF.

Enables read access to the current VFS file's properties.

Provides access to the resources for the JSP EL.

Loads resources from the OpenCms VFS.

Enables automatic parameter escaping for the current flex request.

Splits a JSP page into elements to be included by the <cms:include>-tag.

Enables access to the properties of the currently logged in user.

Performs user tracking actions like visit resources or subscribe/unsubscribe.

Please consult the taglib documentation for more information on the individual tags and their attributes.

The following functions are available in the OpenCms standard taglib. A function can be accessed by calling:

${cms:functionName(parameters)}

Allows conversion of Long values to Dates. Can also handle Strings that represent a Long or a Date.

Returns a list of attribute values specified by the attribute name of the items of the given list.

Allows conversion of Objects to Locales. Can also handle Strings that are locales, or Locales itself.

Allows conversion of String values to CmsUUIDs. Can also handle byte[] that are CmsUUIDs, or CmsUUID itself.

Encodes a String in a way that is compatible with the JavaScript escape function.

Returns the current OpenCms user context from the page context.

Returns the size of the given list.

Returns the link without parameters from a String that is formatted for a GET request.

Returns the value of a parameter from a String that is formatted for a GET request.

Uses the first String as key to look up from the map that is passed as the second String, and returns either the element found or the empty String. The map String must have the form key1:value1|key2:value2 etc.

Uses the first String as key to look up from the map that is passed as the second String, and returns either the element found or the default value from the third String. The map String must have the form key1:value1|key2:value2 etc.

Returns the current navigation URI.

Strips all HTML markup from the given input.

Returns a substring of the input, which isn’t longer than the given int value.

Decodes a String in a way that is compatible with the JavaScript unescape function.

Provides simple access to a OpenCms JSP/EL content VFS access bean.

Please consult the taglib documentation for more information on the individual functions and their arguments.

Related links

The taglib reference (TLDDoc) provides the most detailed information for each tag.