How to write JSP scriptlet code using the OpenCms API

The functionality of the OpenCms JSP Taglib can also be accessed by using a single Java Bean: com.opencms.flex.jsp.CmsJspActionElement. To develop JSP pages using the OpenCms API, programmers are not fixed to a certain approach. Both the OpenCms JSP taglib and the CmsJspActionElement offer the same options. In fact, both ways execute the same internal code! Experienced Java programmers can find an equivalent method in the Bean CmsJspActionElement for each tag of the OpenCms Taglib. For a detailed description of the OpenCms JSP Taglib, please refer to the OpenCms JSP Taglib documentation which is available as a separate module.

Put this code snippet in the head of your JSP page to initialize the CmsJspActionElement as a Java Bean:

<jsp:useBean id="cms" class="com.opencms.flex.jsp.CmsJspActionElement">
<% cms.init(pageContext, request, response); %>
</jsp:useBean>

Because the CmsJspActionElement requires the current pageContext, request and response instances, you do have to invoke the init() method! Alternatively, an instance of CmsJspActionElement can also be created by passing these values as parameters to the CmsJspActionsElement's second constructor like this:

<% com.opencms.flex.jsp.CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response); %>

The next pages describe the usage of the different methods provided with the CmsJspActionElement. The Javadocs for the CmsJspActionElement are included, too.

]]>