Filters wrap around servlets. They obviate the need to replicate code that needs to be executed on requests to any servlet.
As they are pluggable, they're far easier replaced than some abstract base class (a prime example of composition over inheritance).
Think of things like validating requests, adding specific fields to responses, analysing headers, logging requests and responses, things like that.
Or add some functionality to an application when you can't change the actual servlet code itself.
Main Topics
Browse All Topics





by: Tuno85Posted on 2009-07-26 at 22:37:48ID: 24949043
Do you mean how to use it in the web.xml or why using a filter?
Select allOpen in new window