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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.