2.7. Welcome to Tapestry Lite!

Tapestry Lite is really developer lite! It is lite only because we don't have to provide all the specifications to get a simple application going. Here we will see how to display the greeting with just two small files.

Home.html. 

<html>
    <body>
        Welcome to Tapestry Lite!
    </body>
</html>

This file is the template file that will be placed under the context. Tapestry has search algorithms to find its necessary resources. And the context is one of the places it will look for templates.

web.xml. 

<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>
    <servlet>
        <servlet-name>WelcomeLite</servlet-name>
        <servlet-class>
            org.apache.tapestry.ApplicationServlet
        </servlet-class>
        <load-on-startup>0</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>WelcomeLite</servlet-name>
        <url-pattern>/app</url-pattern>
    </servlet-mapping>
</web-app>

This is the standard web application deployment descriptor that goes under the standard WEB-INF folder.

As you may have already noticed, we have skipped a couple of the specification files. That's right, these files are not necessary; not necessary for us to provide but Tapestry will create default stand-in resources internally and use them to function normally.

So here's a high level sequence of steps that take place when the application is loaded and accessed.

  1. When the application is first accessed, Tapestry will look for an <init-param> by the name org.apache.tapestry.application-specification. If it doesn't find one, it will look for the application specification file in WEB-INF by the name servlet-name.application. If it doesn't find either, it will create a default stand-in specification and use it. The stand-in specification will use the BaseEngine as the engine for the application.

  2. Next, Tapestry will parse the request and try to identify the requested page. If no page was identified or if the requested page does not exist in the application, Tapestry will by default invoke the Home page.

  3. Tapestry will look for the page declaration in the application specification file, if not found, it will look for the page specification file in WEB-INF, if not found there either, it will create a default stand-in page specification and use it. The stand-in specification will use BasePage as the page class and page-name.html as the page template.

  4. Look for page-name.html in the context, load the template and render it.