views:

149

answers:

2

I would like to apply a filter to severl url endings. The next configuraiton seems to work.

<filter>
    <filter-name>LanguageFilter</filter-name>
    <filter-class>filters.LanguageFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>LanguageFilter</filter-name>
    <url-pattern>*.do</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>LanguageFilter</filter-name>
    <url-pattern>*.xml</url-pattern>
</filter-mapping>

Originally I asked if it was possible to use wildcards such as:

    <url-pattern>*.do|*.xml</url-pattern>

But it does not seem to be possible.

+1  A: 

There is no notion of such an operator in the standard, so you need two mappings. The specification of the mappings is available in the servlet specification. See this article for a link and section.

disown
A: 

You could cheat a bit, and map /. to your filter class, then have your Filter Implementation take a parameter where .do|.xml are parsed and though your filter, technically is able to see too much, it does a simply check on whether or not you've given it an additional test, does the test, and either filter's or noops.

Nathan Feger