I am programming a web application with filters that run XSLT's (using
Xalan) against the XML written out by servlets. I have also created servlets
to serve as error pages by writing out error messages as XML documents,
which then get transformed into user-friendly HTML by filters that use XSLT.
I map these error servlets to a path, and associate certain exceptions with
those paths.
Unfortunately for me, the filters are not used when the error servlets get
called. If I request the path to the error servlets directly from a browser,
then the filters are used. However, when a servlet throws an exception that
is mapped to a path that happens to be filtered, the filters are not used.
(If the path is mapped to a servlet, then the servlet is called, but any
filters mapped to that path are ignored).
If an error-page is mapped to a location that happens to be mapped to 1+
filters and 0 or 1 servlets, are the filter-mapping elements really meant to
be ignored while the servlet-mapping elements are respected?
Does the RequestDispatcher work the same way (ignoring filter-mapping
elements and respecting servlet-mapping elements)?
I have tried to make sense of the Servlet 2.3 spec, but I can not find a
place where it describes how filters work with error-page elements and
RequestDispatcher objects.
Here is a selection from my web.xml file:
<filter>
<filter-name>DirectoryTemplates</filter-name>
<description>
Applies the specified XSLT.
</description>
<filter-class>ca.capilanocollege.servlet.xml.TemplatesFilter</filter-class>
<init-param>
<param-name>templatesUrl</param-name>
<param-value>/directory/directory.xsl</param-value>
</init-param>
</filter>
<filter>
<filter-name>DirectoryExceptionTemplates</filter-name>
<description>
Applies the specified XSLT.
</description>
<filter-class>ca.capilanocollege.servlet.xml.TemplatesFilter</filter-class>
<init-param>
<param-name>templatesUrl</param-name>
<param-value>/directory/directory-exception.xsl</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>DirectoryTemplates</filter-name>
<servlet-name>Directory</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>DirectoryExceptionTemplates</filter-name>
<servlet-name>DirectoryException</servlet-name>
</filter-mapping>
<servlet>
<servlet-name>Directory</servlet-name>
<description>
Searches all employees and administrators working at Capilano College.
</description>
<servlet-class>ca.capilanocollege.names.servlets.Directory</servlet-class>
<load-on-startup/>
</servlet>
<servlet>
<servlet-name>DirectoryException</servlet-name>
<servlet-class>ca.capilanocollege.servlet.xml.ExceptionToXmlServlet</servlet
-class>
<load-on-startup/>
</servlet>
<servlet-mapping>
<servlet-name>Directory</servlet-name>
<url-pattern>/directory/directory.serv</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>DirectoryException</servlet-name>
<url-pattern>/directory/directory-exception.serv</url-pattern>
</servlet-mapping>
<error-page>
<exception-type>ca.capilanocollege.names.exceptions.DirectoryException</exce
ption-type>
<location>/directory/directory-exception.serv</location>
</error-page>
Thank you so much,
Nathan
~~>
Nathan Vick
Programmer/Analyst
Capilano College
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>