Openmcs cms:info tag explained

March 31, 2011 6:35 pm 0 comments

<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’:

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:

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:

opencms.url:

opencms.uri:

opencms.webapp:

opencms.webbasepath:

opencms.request.uri:

opencms.request.element.uri:

opencms.request.folder:

Non usual OpenCms Parameters

opencms.request.encoding:

opencms.request.locale:

Some system properties

java.class.version:

java.class.path:

java.library.path:

java.vm.vendor:

file.separator:

java.io.tmpdir:

user.dir:

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!

javi

Let’s push your website a bit further

My name is Javier Márquez and I have more than 10 years of web programming and web designing experience. If you have a difficult development to complete, maybe you can stop by and see what I can do for you. You can find me on and Twitter.

Leave a reply


contact meAnything related to web development like javascript and CSS to create responsive designs, or PHP and node.js to make your website work properly, is my pleasure. If you have an interesting project in mind, I can help to make it real.