All Tapestry applications make use of the ApplicationServlet
class as their
servlet; it is rarely necessary to create a subclass.
Example 5.1. Web Deployment Descriptor
<?xml version="1.0"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <distributable/> <display-name>My Application</display-name> <servlet> <servlet-name>myapp</servlet-name> <servlet-class>org.apache.tapestry.ApplicationServlet
</servlet-class> <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> <servlet-name>myapp</servlet-name> <url-pattern>/app</url-pattern> </servlet-mapping> <filter> <filter-name>redirect</filter-name> <filter-class>org.apache.tapestry.RedirectFilter
</filter-class> </filter> <filter-mapping> <filter-name>redirect</filter-name> <url-pattern>/</url-pattern> </filter-mapping> <session-config> <session-timeout>15</session-timeout> </session-config> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app>
This indicates to the application server that the Tapestry application may be clustered. Most application servers ignore this element, but future servers may only distribute applications within a cluster if this element is present.
| ||||
The servlet name may be used when locating the application specification (though not in this example). | ||||
The servlet class is nearly always | ||||
It is generally a good idea to specify
| ||||
The servlet is mapped to
Using | ||||
This filter sends a client redirect to the user when they access the web application context. The filter
sends a client redirect to the user's browser, directing them to the application servlet. In this way,
the "public" URL for an application can be |
On initialization, the Tapestry servlet will locate its application specification; a file that identifies details about the application, the pages and components within it, and any component libraries it uses. Tapestry provides a great deal of flexibility on where the specification is stored; trivial Tapestry applications can operate without an application specification.
The specification is normally
stored under WEB-INF
. In fact, Tapestry performs a search to find the specification:
On the classpath, as defined by the org.apache.tapestry.application-specification
configuration parameter.
As /WEB-INF/
.
The name
/name
.applicationname
is the servlet name. This location
is only used in the rare case of a single WAR containing multiple Tapestry
applications.
As /WEB-INF/
.
Again, name
.applicationname
is the
servlet name. This is the standard location.
If the application specification still can not be found, then an empty, "stand in" application specification is used. This is perfectly acceptible ... an application specification is typically needed only when an application makes use of component libraries, or requires some other kind of customization only possible with an application specification.