I am having problem using filter mapping in in Tomcat 5.0 on windows
I tried the following in my web.xml.
...
<filter-mapping>
<filter-name>foo.bar.MyFilter</filter-name>
<url-pattern>/content/*.jsp</url-pattern>
</filter-mapping>
...
When I start Tomcat it tells me:
SEVERE: Parse error in application web.xml
java.lang.IllegalArgumentException: Invalid <url-pattern> /content/*.jsp in
filter mapping
at org.apache.commons.digester.Digester.createSAXException(Digester.java:2540)
at org.apache.commons.digester.Digester.createSAXException(Digester.java:2566)
at org.apache.commons.digester.Digester.endElement(Digester.java:1061)
...
It doesn't do it in a friends Tomcat 4.1 on Linux
Is this some kind of change in behavior from Tomcat 4.0 to 5.0?
(Tomcat 5.0 is Servlet API 2.4 and JSP 2.0)
The idea is that I want it to run my this filter before all JSP pages, but
not with all .jpg, .gif requests that come in, even if they are within
the some directory structure.
Seems simple enough in the example from a friends Tomcat 4.0
-Paul
P.Hill - 28 Feb 2004 04:57 GMT
> <filter-mapping>
> <filter-name>foo.bar.MyFilter</filter-name>
> <url-pattern>/content/*.jsp</url-pattern>
> </filter-mapping>
Upon further reading, I have discovered that my
friend can't be trusted. *.jsp doesn't work in
4.1, and it complains as I reported in 5.0.
My solution at this time is to allow requests
for things other than jsps through the same
filter to skip the filtering, since the filter
doesn't need to kick in just because someone
is asking for background.jpg or some such.
Yeah, I know we might consider rearranging the
dir structure to put jsps separate from content,
but that doesn't seem like a useful step at this
time.
Other ideas?
-Paul
DelGurth - 27 Aug 2004 15:02 GMT
We had the same problem with a jsp-property-group url-pattern, and I did
some searches on google on this topic (that's how I ended up in here for
example)
Most clear result I found was:
http://www.mail-archive.com/tomcat-dev@jakarta.apache.org/msg43676.html
Where it says that mapping /somepath/*.something worked in a version of
tomcat, but is removed since it does not comply with the Servlet
specification.
This is what the servlet specification (2.4) allows:
- A string beginning with a / character and ending with a /* suffix is
used for path mapping.
- A string beginning with a *. prefix is used as an extension mapping.
- A string containing only the / character indicates the "default" servlet
of the application. In this case the servlet path is the request URI minus
the context path and the path info is null.
- All other strings are used for exact matches only.
So what you (and we) are trying to do, cannot be done according to the
Servlet 2.4 specification.