Skip to end of metadata
Go to start of metadata

Introduction

This tutorial teaches you how to set up SiteMesh within a Java Web Development Environment and should take about 5 minutes or less.

Icon

Shortcut: Don't have a development environment handy or know how to set one up? Download the "no install" SiteMesh Starter Kit which complets the steps below and skip straight to Start Using SiteMesh in 10 Minutes.

Setup Web Application

Setup your web application with your favourite JEE IDE such as Eclipse or the Spring Tool Suite.

If you are new to JEE development and plan to follow along with the Start Using SiteMesh in 10 Minutes tutorial, use the context root of cafe.

Install SiteMesh Manually

Installing SiteMesh into your web application consists of three steps,

  1. Add the SiteMesh library file to WEB-INF/lib
  2. Add the SiteMesh filter to web.xml
  3. Create a blank decorators.xml file

Setup Library File

Copy the SiteMesh jar file into your web application's WEB-INF/lib directory. In this example we downloaded SiteMesh 2.4.1 which uses the jar name, sitemesh-2.4.1.jar.

Add SiteMesh Filter

Add the following to WEB-INF/web.xml within the <web-app> tag,

Here is a sample web.xml,

Sample web.xml  Expand source

Add Decorator Controller File

Create the a decorators.xml file in your WEB-INF directory,

decorators.xml
Icon

You IDE (Integrated Development Environment) may give you the warning, "No grammar constraints (DTD or XML schema) detected for the document."

This is just a warning (happens with many other xml files) and you can ignore it or disable the warning in your IDE.

If you start up your application server (container) and get no errors then SiteMesh is is ready to go. However, SiteMesh will not do anything yet. Continue to Start Using SiteMesh in 10 Minutes.