This project has retired. For details please refer to its Attic page.
Apache Tiles - Framework - Tiles Configuration Fork me on GitHub

Configuring Tiles in your web application

Tiles has always been a web application package, usually used in conjunction with Struts. Apache Tiles™ evolved to the point of being technology-independent, but its use in a Servlet-based web application is still the most frequent use case.

Required libraries

The first thing is to install the required libraries. For the purpose of this tutorial, we will install everything: the more we can do, the better. Just know that a more "lightweight" but limited configuration is available.

If you're using maven, just include this dependency, it will include the rest:


If you're not using maven, just download tiles and copy all the jars into the /WEB-INF/lib directory.

Starting Tiles engine

Load the tiles container by using the appropriate listener it in your web.xml file. Since we decided to load everything, we'll use CompleteAutoloadTilesListener:


For this tutorial, we'll configure Tiles to work directly with the servlet API, without a controller. In the real world, you'll probably use an MVC framework like Struts or Shale or Spring. You have to configure your framework to work with Tiles; please refer to your framework's documentation for that. For now, we'll just declare TilesDispatchServlet in web.xml:

    <servlet-name>Tiles Dispatch Servlet</servlet-name>
    <servlet-name>Tiles Dispatch Servlet</servlet-name>

This means that any request to an URL ending in ".tiles" will be dispatched directly to the matching Tiles Definition.