Chapter 5. Servlet and JSP Filters

Topics in This Chapter

  • Designing basic filters
  • Reading request data
  • Accessing the servlet context
  • Initializing filters
  • Blocking the servlet or JSP response
  • Modifying the servlet or JSP response
  • Using filters for debugging and logging
  • Using filters to monitor site access
  • Using filters to replace strings
  • Using filters to compress the response
  • Configuring filters for different request types

A filter is a program that runs on the server before the servlet or JSP page with which it is associated. A filter can be attached to one or more servlets or JSP pages and can examine the request information going into these resources. After doing so, it can choose among the following options:

  • Invoke the resource (i.e., the ...

Get Core Servlets and JavaServer Pages, Volume 2: Advanced Technologies, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.