Metawerx Java Hosting Small Logo


This tag specifies a filter name, and either a URL mapping or servlet name, for a filter that has been defined with the <filter> tag.

Multiple <filter-mapping> tags can be specified for a single <filter>, providing different URL patterns. See the <url-pattern> tag for examples.

The <filter-mapping> has two required elements:

If a servlet name is specified, the filter will be called whenever the specific servlet is called.

Order of elements in web.xml

  • Despite some developers stating that the order of elements in web.xml must follow an exact order, for the most part this is incorrect. However, some elements must be defined before others. Filter and filter-mapping are one such example.
  • A filter-mapping must not be defined in web.xml before the matching filter entry. For example, the following will not work, and will throw an java.lang.IllegalArgumentException: Filter mapping specifies an unknown filter name SomeFilterName.
metawerx specific

referring pages