I inherited a Struts 1 app that heavily utilizes FilterChain and I don’t understand the benefit of this extremely obfuscating code.
“In the Servlet API, you normally use a Servlet when you want to control, preprocess and/or postprocess specific requests. But when you want to filter/modify common requests and/or responses based on specific conditions, then a Filter is much more suitable.”
Every request in my app is based on specific conditions, e.g., a merchant id or a search term. But it seems like placing a request inside a whole chain of stuff that completely hides what is going on from the developer trying to trace the cause of an error, is nuts.
My coworker (who’s not registered on SO) explained that it’s for applying global functionality to an app that you don’t want to do in every single controller, such as checking if the user is logged in.