liveBook · Manning

Servlet filter

A servlet filter is a Java web component that intercepts requests and responses in a servlet-based application to process, modify, or reject them.

How 3 Manning books explain it

ASP.NET Core in Action, 3e

IActionFilter is an ASP.NET Core interface for synchronous MVC filters that run before and after action-method execution.

How it is used
Extracts shared checks and other cross-cutting logic from MVC action methods.
How deep it goes
Explains execution timing, context access, short-circuiting, scope, and dependency injection for synchronous action filters.
Examples
Uses ModelState validation and a recipe existence check to demonstrate returning errors before an action executes.
What you can do after
Apply synchronous action filters to MVC actions and configure short-circuit results and injected services.

Read how ASP.NET Core in Action, 3e explains servlet filter →

Spring Security in Action, Second Edition

An HTTP filter is a web-processing component that intercepts and can modify or reject HTTP requests and responses.

How it is used
Intercepts requests to validate input, extend authentication, audit events, or alter processing before responses reach clients.
How deep it goes
Descends from chain ordering to doFilter implementation and stops short of enumerating every framework-provided filter.
Examples
Uses Request-Id validation, authentication-event logging, curl requests, HTTP 400 responses, and OncePerRequestFilter.
What you can do after
Build it from scratch by implementing Filter, control chain placement with HttpSecurity, and select a Spring base class when justified.

Read how Spring Security in Action, Second Edition explains servlet filter →

Kubernetes in Action, Second Edition

A Gateway API filter is a route-rule operation that modifies, mirrors, or otherwise processes requests and responses.

How it is used
Processes matched HTTP or gRPC traffic by modifying, rewriting, redirecting, mirroring, or extending route behavior.
How deep it goes
Defines filter types and concrete manifests, then demonstrates results with requests and logs, stopping at route configuration and behavior.
Examples
Uses header manifests, path replacement, HTTPS redirection, service mirroring, curl requests, and backend pod logs.
What you can do after
Operate/configure HTTPRoute and GRPCRoute rules for header changes, path rewrites, redirects, traffic mirrors, and custom filters.

Read how Kubernetes in Action, Second Edition explains servlet filter →

Also covered in

What to know first

Related concepts

Questions about servlet filter

What is servlet filter?

A servlet filter is a Java web component that intercepts requests and responses in a servlet-based application to process, modify, or reject them.

Which Manning books explain servlet filter?

ASP.NET Core in Action, 3e, Spring Security in Action, Second Edition and Kubernetes in Action, Second Edition.

What should I know before learning servlet filter?

Manning books that teach servlet filter usually introduce authorization, handler, HTTP request and HTTP status code first.

What kinds of servlet filter are there?

Kinds of servlet filter include authorization filter, exception filter and ExtensionRef.

What is servlet filter part of?

Servlet filter is part of filter chain. A filter chain is an ordered sequence of filters through which a request is processed, with each filter able to pass processing to the next.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.