Openmcs cms:info tag explained

<cms:info> is one of the most useful tags of the OpenCms taglib, but when I have a look at other's code I can see that people prefer other ways to get the same results that this tag offers just writing one line.I think that happens because a lack of documentation and examples about it. Googleing a little about this tag you can find two main sources of documentation:

  • Opencms cms:info tag docs
  • Opencms cms:info tag tests
That is the original documentation packed with opencms, a really short explanation of some of the possible properties and a test for these properties where some of them returns the same result, so you can't see the differences between them.

I think I made a better example where I explain a little bit how the cms:info tag works and where you can see those differences.

The example has 3 files:
  • cmsinfo_probe1.jsp: Make an import of cmsinfo_probe2.jsp.
  • cmsinfo_probe2.jsp: Load a xml content and print the cms:info properties
  • element.html: A xml content to be loaded from cmsinfo_probe2.jsp and make some experiments.
I attach a zip with the test files.

In cmsinfo_probe1.jsp we make an import, this way we will be able to see de differences between 'opencms.uri' and 'opencms.request.uri':

<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<cms:include page="cmsinfo_probe2.jsp" />

In cmsinfo_probe2.jsp a contentload is made because i thought that maybe the 'opencms.request.element.uri' parameter was going to show the uri of the element loaded by <cms:contentload>. I was wrong:

<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>cms:info probe</title>
</head>
<body>
  <cms:contentload collector="singleFile" param="%(opencms.folder)element.html">
  <h3>OpenCms Parameters</h3>
  <b>opencms.version:</b> <pre><cms:info property="opencms.version" /></pre><br/>
	<b>opencms.url: </b><pre><cms:info property="opencms.url" /></pre><br/>
	<b>opencms.uri:</b> <pre><cms:info property="opencms.uri" /></pre><br/>
	<b>opencms.webapp</b>: <pre><cms:info property="opencms.webapp" /></pre><br/>
	<b>opencms.webbasepath</b>: <pre><cms:info property="opencms.webbasepath" /></pre><br/>
	<b>opencms.request.uri</b>: <pre><cms:info property="opencms.request.uri" /></pre><br/>
	<b>opencms.request.element.uri</b>: <pre><cms:info property="opencms.request.element.uri" /></pre><br/>
	<b>opencms.request.folder</b>: <pre><cms:info property="opencms.request.folder" /></pre><br/>
		<h3>Non usual OpenCms Parameters</h3>
	<b>opencms.request.encoding</b>: <pre><cms:info property="opencms.request.encoding" /></pre><br/>
	<b>opencms.request.locale</b>: <pre><cms:info property="opencms.request.locale" /></pre><br/>
		<h3>Some system properties</h3>
	<b>java.class.version</b>: <pre><cms:info property="java.class.version" /></pre><br/>
	<b>java.class.path</b>: <pre><cms:info property="java.class.path" /></pre><br/>
	<b>java.library.path</b>: <pre><cms:info property="java.library.path" /></pre><br/>
	<b>java.vm.vendor</b>: <pre><cms:info property="java.vm.vendor" /></pre><br/>
	<b>file.separator:</b> <pre><cms:info property="file.separator" /></pre><br/>
	<b>java.io.tmpdir</b>: <pre><cms:info property="java.io.tmpdir" /></pre><br/>
	<b>user.dir</b>: <pre><cms:info property="user.dir" /></pre><br/>
</cms:contentload>
</body>
</html>

As you can see in the code, i try two parameters that are not in the official documentation (at least in the examples) but I could see in the source code of the taglib. They are 'opencms.request.encoding' and 'opencms.request.locale'.

At the end of the jsp I try some java System properties, some of them I consider that they are more useful than the ones that opencms gives in those examples. Anyway, you can use as property anyone that you can retrieve by using the System.getProperty() method, you can check what are they for JAVA SE5.

The following is the result I got when I made click on cmsinfo_probe1.jsp from my OpenCms explorer:

OpenCms Parameters

opencms.version:
7.5.2
opencms.url:
http://localhost:8080/opencms752/opencms/system/modules/probes/resources/pruebas/cmsinfo/cmsinfo_probe2.jsp
opencms.uri:
/opencms752/opencms/system/modules/probes/resources/pruebas/cmsinfo/cmsinfo_probe2.jsp
opencms.webapp:
opencms752
opencms.webbasepath:
C:optTomcat5.5webappsopencms752
opencms.request.uri:
/system/modules/probes/resources/pruebas/cmsinfo/cmsinfo_probe1.jsp
opencms.request.element.uri:
/system/modules/probes/resources/pruebas/cmsinfo/cmsinfo_probe2.jsp
opencms.request.folder:
/system/modules/probes/resources/pruebas/cmsinfo/

Non usual OpenCms Parameters

opencms.request.encoding:
ISO-8859-1
opencms.request.locale:
es

Some system properties

java.class.version:
49.0
java.class.path:
C:optTomcat5.5binbootstrap.jar;C:optTomcat5.5binojdbc14-10.2.0.3.jar
java.library.path:
C:optTomcat5.5bin;.;C:WINDOWSsystem32;C:WINDOWS;D:oracleproduct10.1.0Db_1bin;D:oracleproduct10.1.0Db_1jre1.4.2binclient;C:oracleapporacleproduct10.2.0serverbin;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSsystem32nls;C:WINDOWSsystem32nlsESPANOL;C:Archivos de programaIntelDMIX;C:optjdk1.5.0_17bin;C:grailsbin;C:Archivos de programaTortoiseGitbin;C:Archivos de programaKaspersky LabKaspersky Anti-Virus 6.0 for Windows Workstations MP4
java.vm.vendor:
Sun Microsystems Inc.
file.separator:

java.io.tmpdir:
C:optTomcat5.5temp
user.dir:
C:optTomcat5.5
The results tell us that 'opencms.request.uri' returns the path to the page requested by the user and all other uri's and url's refers to the current jsp that executes the code.

The property 'opencms.request.folder' also refers to the folder of the page requested by the user, in the example it would be the 'cmsinfo_probe1.jsp' folder.

Hope this helps somebody!

© arqex 2023
Someday,
we'll find ourselves
far, far away...
Transitions here have been created using a library of mine:
React interactable.
This awesome hyperspace effect thanks to this codepen from Noah Blon.
Software development can be fun!
Javier Márquez
Software developer