Filters are a way of executing code before and after a resource (like a servlet or JSP) gets executed. They're good for doing things that should be done for many requests, but that have nothing to do with the current request. Frequently filters are used for things like checking authentication (so that it doesn't have to be hard-coded everywhere), or to compress the response.
Filters should not be used to replace functionality that is specific to a request.