You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Steve Farmer <to...@steve-farmer.com> on 2005/03/23 23:50:01 UTC

Filter-mapping

I've created a "toy" filter and servlet to experiment with filters in 
Tomcat 5.0.28. If I map the filter to the servlet like this

<filter-mapping> ...
      <dispatcher>ERROR</dispatcher>
... </filter-mapping>

and invoke the following JSP

<%@ page errorPage="/filtex-dummy.do" %>
${10%0} <%-- throw exception --%>

then the servlet executes but the filter does not. If I change the 
mapping to

<filter-mapping> ...
      <dispatcher>FORWARD</dispatcher>
... </filter-mapping>

then both the filter and the servlet execute.

A lengthy search seems to indicate that other folks have encountered 
this, but I can't determine whether it's a bug or just a 
misunderstanding of the standard. If it's my misunderstanding, please 
point me to an explanation of when

	<dispatcher>ERROR</dispatcher>

will cause the filter to execute.

Note: the v2.4 servlet spec seems to indicate that the <filter-mapping> 
must use <url-pattern> when <dispatcher> has a value of ERROR, but I 
tried both <servlet-name> and <url-pattern> with no apparent difference 
in behavior.

Thanks in advance and best regards,
Steve Farmer


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Filter-mapping

Posted by Steve Farmer <to...@steve-farmer.com>.
Please accept my apology for my previous inappropriately formatted
message. (At least I hope that's the reason it was ignored.) If I'm
in the wrong forum, please accept my additional apologies and direct
me to an appropriate forum. If I need to "RTFM", please tell me
which "FM" I need to "R" 'cause I've studied multiple books and the
Java Servlet Spec 2.4, and I still don't understand this behavior. A
search of the web turned up some other folks who may have observed
the same behavior, but as far as I can tell they're just as confused
about it as I am.

I'm experimenting with filters in Tomcat 5.0.28 to test my
understanding. In one test I have the following

<filter-mapping> ...
    <dispatcher>ERROR</dispatcher>
... </filter-mapping>

and I try to stimulate it with the following JSP

<%@ page errorPage="/filtex-dummy.do" %>
${10%0} <%-- throw exception --%>

The servlet runs and receives the request attributes that an error
handler expects, but the filter does not run. However, if I change
ERROR to FORWARD, then both the filter and the servlet run.

JSS 2.4 seems to indicate that the <filter-mapping> must use
<url-pattern> when <dispatcher> has a value of ERROR, but I tried
both <servlet-name> and <url-pattern> with no apparent difference
in behavior.

My questions are
* Is this standard behavior or is it peculiar to Tomcat?
* In either case, is it possible to trigger the filter when
   <dispatcher> = ERROR? If so, how?

Thanks in advance and best regards,
Steve Farmer
tomcat-user@steve-farmer.com


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org