You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Howard M. Lewis Ship" <hl...@attbi.com> on 2003/05/04 22:45:01 UTC
RedirectFilter
One complaint about Tapestry is the base URL is typically something like
"http://foo/context/app". People would prefer "http://foo/context" and not
worry about the "/app" part. Some folks have used an index.html with a
<meta> redirect.
Just checked in a better solution, RedirectFilter.
RedirectFilter is the first thing in Tapestry to use anything newer than the
Servlet 2.2 API. It is a Servlet Filter, first available in Servlet API
2.3, ... but it is optional and the rest of Tapestry sticks to 2.2.
The filter is configured to catch references to the "naked" servlet context
(i.e., "http://foo/context" or "http://foo/context/") and send a client
redirect to the Tapestry application (i.e., "http://foo/context/app"). The
default servlet path is "/app", but may be overriden with an <init-param>
for name "redirect-path".
Works like a charm; you add the following before the first <servlet> in the
web.xml:
<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>
Also, you have to use the 2.3 DTD ... which nearly everyone now supports
(including Jetty, JBossWeb and Tomcat).
--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry