Book Image

Building Websites with OpenCms

Book Image

Building Websites with OpenCms

Overview of this book

This book takes you through the process of creating content-rich websites and applications using OpenCms. Although powerful and flexible, OpenCms can be daunting on first approach, but its advanced features reward the investment in learning. This book exists to ease Java developers into getting the most from OpenCms. OpenCms OpenCms is a professional-level, open source Website Content Management System, with which you can create and manage complex websites. Based on Java and XML technology, it fits into almost any modern IT environment. With hard-won experience of the practical difficulties faced by developers working with OpenCms, this book is the embodiment of the author's expertise, and the perfect way to master the system.
Table of Contents (12 chapters)
Building Websites with OpenCms
About the Author


OpenCms is an open-source enterprise-grade content management system based on Java and XML technology, and is designed specifically for creating and maintaining websites. It provides a full set of tools for dealing with content creation, editorial workflow, publishing, and versioning.

In this book we will take you through the process of constructing an OpenCms website, showing you how to work with OpenCms, customize and extend your system with Java libraries and classes, JSP pages, and XML templates, and how to administer and deploy your OpenCms solution.

Like many of the open-source content management systems, OpenCms is daunting on first use, but its power and flexibility reward the investment in learning to use it. This book exists to ease you into getting the most from OpenCms.

What This Book Covers

Chapter 1 gives us an introduction to OpenCms, its features, and its history. Chapter 2 walks us through the process of installing and configuring OpenCms. We look at installing OpenCms with its setup wizard, securing and troubleshooting the installation, and configuring the client.

Chapter 3 explores the OpenCms Workplace; this is the primary interface for managing the contents of your OpenCms repository, and includes tools for editing, project management, workflow, publishing, and server administration. In this chapter, we cover various aspects of working in the OpenCms Workplace, including managing projects, using modules, permissions, editing and publishing documents, creating new pages, and customizing the Workplace.

In Chapter 4 we turn our attention to customizing the site. We look at developing the look and feel of published content, adding dynamic elements, and controlling resources. This includes topics such as working with templates, using OpenCms JSP tag libraries, creating JSP scriptlets, and managing FlexCache directives.

Chapter 5 takes us into the heart of OpenCms, looking at the mechanisms that drive the content management system. We look at resource types, content definitions, the Virtual File System (VFS), and the class structure of OpenCms.

In Chapter 6 we look at OpenCms modules; these provide a mechanism for extending the functionality of OpenCms. Modules are designed to be easily distributed among OpenCms installations, and can provide functional elements ranging from portable content to sophisticated applications that interact with content in OpenCms. We take an in-depth look at developing modules, covering topics such as creating a module, adding templates, content, and JSP pages to the module, adding custom Java classes and libraries, and exporting and deploying your module.

Chapter 7 tackles some advanced features of the OpenCms module mechanism. We cover creating an administration point for a module, using JSPs to produce administration screens, and creating a custom launcher class.

In Chapter 8 we return to the administrative aspect of managing OpenCms, and examine the issues surrounding the deployment of an OpenCms solution. We cover static exports, user authentication and management, and other administrative tasks such as backup, recovery, and performance tuning.

There are two appendices that cover building OpenCms from its sourcecode, and installing, configuring, and using the OpenCms Lucene Module to improve the searching of your site.

What You Need for Using This Book

To use this book, you will of course need OpenCms. This is freely downloadable from

OpenCms has its own requirements for installation: Java 2 SDK version 1.4 or higher, Apache Tomcat 4.x, and MySQL 3.23.x or higher.

You will find details of where to download these applications from in Chapter 2, but each is freely available.

A sound knowledge of Java, JSP, and XML will help you get the most out of this book.


In this book you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

There are three styles for code. Code words in text are shown as follows: "Rather than get the contents of myFile with the getContents() method, we construct a new CmsXmlControlFile object".

If we have a block of code, it will be set as follows:

CmsJspActionElement cms = new CmsJspActionElement( pageContext,
                                                   response );
String myFileName = "/playground/index.html";
CmsObject cmso = cms.getCmsObject();
CmsFile myFile = cmso.readFile( myFileName );

When we wish to draw your attention to a particular part of a code block, the relevant lines will be made bold:

CmsJspActionElement cms = new CmsJspActionElement( pageContext,
                                                   response );
String myFileName = "/playground/index.html";

CmsObject cmso = cms.getCmsObject();
CmsFile myFile = cmso.readFile( myFileName );

New terms and important words are introduced in a bold-type font. Words that you see on the screen—in menus or dialog boxes, for example—appear in the text as follows: "Clicking the Next button moves you to the next screen".

Any command-line input and output is written as follows:

mysql> create table books (name char(100), author char(50));
Query OK, 0 rows affected (0.03 sec)

Reader Feedback

Feedback from our readers is always welcome. Let us know what you think about this book, what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply drop an e-mail to , making sure to mention the book title in the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the Suggest a title form on or e-mail .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on

Customer Support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the Example Code for the Book

Visit, and select this book from the list of titles to download any example code or extra resources for this book. The files available for download will then be displayed.


Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or code—we would be grateful if you could report this to us. By doing this you can save other readers from frustration, and also help to improve subsequent versions of this book.

If you find any errata, report them by visiting, selecting your book, clicking on the Submit Errata link, and entering the details of your errata. Once your errata have been verified, your submission will be accepted and the errata added to the list of existing errata. The existing errata can be viewed by selecting your title from


You can contact us at if you are having a problem with some aspect of the book, and we will do our best to address it.