# Annotation Interface WebFilter

@Target(TYPE) @Retention(RUNTIME) @Documented public @interface WebFilter
The annotation used to declare a Servlet `Filter`.
This annotation will be processed by the container during deployment, the Filter class in which it is found will be created as per the configuration and applied to the URL patterns, `Servlet`s and `DispatcherType`s.
If the name attribute is not defined, the fully qualified name of the class is used.
At least one URL pattern MUST be declared in either the `value` or `urlPattern` attribute of the annotation, but not both.
The `value` attribute is recommended for use when the URL pattern is the only attribute being set, otherwise the `urlPattern` attribute should be used.
The annotated class MUST implement `Filter`. E.g. `@WebFilter("/path/*")`
`public class AnExampleFilter implements Filter { ...`

Since:
  Servlet 3.0 (Section 8.1.2)

## Optional Element Summary

Optional Elements
Modifier and Type
Optional Element
Description
`boolean`
`asyncSupported`
Declares whether asynchronous operation is supported by this Filter.
`String`
`description`
Provides a description of the Filter.
`DispatcherType[]`
`dispatcherTypes`
Declares the dispatcher types to which this Filter applies.
`String`
`displayName`
Provides a display name for the Filter.
`String`
`filterName`
Declares the name of the Filter.
`WebInitParam[]`
`initParams`
Declares initialization parameters for the Filter.
`String`
`largeIcon`
Provides a large icon for the Filter.
`String[]`
`servletNames`
Declares the servlet names to which this Filter applies.
`String`
`smallIcon`
Provides a small icon for the Filter.
`String[]`
`urlPatterns`
Declares the URL patterns to which this Filter applies.
`String[]`
`value`
A convenience method, to allow extremely simple annotation of a class.

## Element Details

### description

String description
Provides a description of the Filter.

Returns:
  description of the Filter, if present

Default:
  `""`

### displayName

String displayName
Provides a display name for the Filter.

Returns:
  display name of the Filter, if present

Default:
  `""`

### initParams

WebInitParam[] initParams
Declares initialization parameters for the Filter.

Returns:
  array of initialization params for this Filter

Default:
  `{}`

### filterName

String filterName
Declares the name of the Filter.

Returns:
  name of the Filter, if present

Default:
  `""`

### smallIcon

String smallIcon
Provides a small icon for the Filter.

Returns:
  small icon for this Filter, if present

Default:
  `""`

### largeIcon

String largeIcon
Provides a large icon for the Filter.

Returns:
  the large icon for this Filter, if present

Default:
  `""`

### servletNames

String[] servletNames
Declares the servlet names to which this Filter applies.

Returns:
  array of Servlet names to which this Filter applies

Default:
  `{}`

### value

String[] value
A convenience method, to allow extremely simple annotation of a class.

Returns:
  array of URL patterns
See Also:
  - `urlPatterns()`

Default:
  `{}`

### urlPatterns

String[] urlPatterns
Declares the URL patterns to which this Filter applies.

Returns:
  array of URL patterns to which this Filter applies

Default:
  `{}`

### dispatcherTypes

DispatcherType[] dispatcherTypes
Declares the dispatcher types to which this Filter applies.

Returns:
  array of DispatcherTypes to which this filter applies

Default:
  `{REQUEST}`

### asyncSupported

boolean asyncSupported
Declares whether asynchronous operation is supported by this Filter.

Returns:
  `true` if asynchronous operation is supported, `false` otherwise

Default:
  `false`