JSPs (Java Server Pages) provide a powerful way to build web pages dynamically. They are the way, web pages are generated in OpenCms. In essence a JSP is a Java program that looks like HTML code and, if executed, creates a HTML page. The particular advantage of a JSP is that arbitrary Java code can be executed to produce HTML output. There are three ways to accomplish dynamic HTML creation by executing Java code:
- Special tags provided via taglibs
- The expression language (EL)
- Writing scriptlet code
In order to keep your JSPs simple and maintainable, it is good style to avoid scriptlet code and use tags and the EL. For more details about JSPs in general, in particular the JSTL (the standard tag libraries) and the EL, please consult the very good books or tutorials around.
When writing JSPs in OpenCms, you should be aware of the following:
- JSPs are managed/added via the OpenCms workplace and have the resource type “jsp”
- Each JSP exists in an “offline” and an “online” version
- JSPs can't be exported statically, but there rendered output can be cached
- To increase performance you might have to alter FlexCache settings
In OpenCms JSPs are used for several purposes:
- Templates that provide for WYSIWYG editable pages
- Formatters for XML contents
- Pages with special functionality, e.g. login forms, search result pages, etc.
To easily create JSPs for the purposes just described, OpenCms comes with a special API for JSPs that consists mainly of two parts:
- The OpenCms taglib
- A set of Java beans to make OpenCms functionality accessible via the EL
This page forwards you to the relevant topics on writing JSPs in OpenCms.