Class GenericFilter

java.lang.Object
jakarta.servlet.GenericFilter
All Implemented Interfaces:
Filter, FilterConfig, Serializable
Direct Known Subclasses:
HttpFilter

public abstract class GenericFilter extends Object implements Filter, FilterConfig, Serializable

Defines a generic, protocol-independent filter. To write an HTTP filter for use on the Web, extend HttpFilter instead.

GenericFilter implements the Filter and FilterConfig interfaces. GenericFilter may be directly extended by a filter, although it's more common to extend a protocol-specific subclass such as HttpFilter.

GenericFilter makes writing filters easier. It provides simple versions of the lifecycle methods init and destroy and of the methods in the FilterConfig interface.

To write a generic filter, you need only override the abstract doFilter method.

Since:
Servlet 4.0
See Also: