Tutorial :Is it possible to use wildcards within J2EE - fitlers?


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:


But it does not seem to be possible.


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.


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.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »