Top Description Methods
jakarta.servlet.annotation

public @Interface WebFilter

extends Annotation
Annotations
@Target:TYPE
@Retention:RUNTIME
@Documented
Imports
java.lang.annotation.Documented, .ElementType, .Retention, .RetentionPolicy, .Target, jakarta.servlet.DispatcherType

The annotation used to declare a Servlet jakarta.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, jakarta.servlet.Servlets and jakarta.servlet.DispatcherTypes.

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 jakarta.servlet.Filter. E.g. @WebFilter("/path/*")
public class AnExampleFilter implements Filter { ...
Since
Servlet 3.0 (Section 8.1.2)

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

asynchronous operation supported by this Filter
asyncSupported
()

public String

Returns:

description of the Filter, if present
description
()

public DispatcherType[]

Returns:

array of DispatcherTypes to which this filter applies
dispatcherTypes
()

public String

Returns:

display name of the Filter, if present
displayName
()

public String

Returns:

name of the Filter, if present
filterName
()

public WebInitParam[]

Returns:

array of initialization params for this Filter
initParams
()

public String

Returns:

the large icon for this Filter, if present
largeIcon
()

public String[]

Returns:

array of Servlet names to which this Filter applies
servletNames
()

public String

Returns:

small icon for this Filter, if present
smallIcon
()

public String[]

Returns:

array of URL patterns to which this Filter applies
urlPatterns
()

public String[]

Returns:

array of URL patterns
value
()

A convenience method, to allow extremely simple annotation of a class.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

asyncSupportedback to summary
public boolean asyncSupported()
Returns:boolean

asynchronous operation supported by this Filter

descriptionback to summary
public String description()
Returns:String

description of the Filter, if present

dispatcherTypesback to summary
public DispatcherType[] dispatcherTypes()
Returns:DispatcherType[]

array of DispatcherTypes to which this filter applies

displayNameback to summary
public String displayName()
Returns:String

display name of the Filter, if present

filterNameback to summary
public String filterName()
Returns:String

name of the Filter, if present

initParamsback to summary
public WebInitParam[] initParams()
Returns:WebInitParam[]

array of initialization params for this Filter

largeIconback to summary
public String largeIcon()
Returns:String

the large icon for this Filter, if present

servletNamesback to summary
public String[] servletNames()
Returns:String[]

array of Servlet names to which this Filter applies

smallIconback to summary
public String smallIcon()
Returns:String

small icon for this Filter, if present

urlPatternsback to summary
public String[] urlPatterns()
Returns:String[]

array of URL patterns to which this Filter applies

valueback to summary
public String[] value()

A convenience method, to allow extremely simple annotation of a class.

Returns:String[]

array of URL patterns

See Also
urlPatterns()