Chapter 7. Servlet Filtering
Filters are new in the Servlet 2.3 specification, enabling you to intercept a request before it reaches a resource. In other words, a filter gives you access to the HttpServletRequest and the HttpServletResponse objects before they are passed in to a servlet.
Filters can be very useful. For example, you can write a filter that records all incoming requests and logs the IP addresses of the computers from which the requests originate. You also can use a filter as an encryption and decryption device. Other uses include user authentication, data compression, user input validation, and so on.
For a filter to intercept a request ...
Get Java for the Web with Servlets, JSP, and EJB: A Developer’s Guide to J2EE Solutions 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.