Chapter 9. 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

Perhaps the single most important new capability in version 2.3 of the servlet API is the ability to define filters for servlets and JSP pages. Filters provide a powerful and standard alternative to the nonstandard “servlet chaining” supported by some early servers.

A filter is a program that runs on the server before the servlet or JSP page with which it is associated. A filter ...

Get More Servlets and JavaServer Pages™ 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.