I have a scenario where, if a user gives my Grails app a certain type of input, I want to dynamically add a javax.servlet.Filter impl (MyCustomerFilter) so that all subsequent requests to the server get passed through this filter.

In other words, when the Grails app starts up, MyCustomFilter is not activated and is not in the filter chain. But when the user does something (let's say makes an AJAX call back to a server-side controller) I want to add MyCustomFilter to the filter chain and activate it (for all future/subsequent requests).

Is this possible? If so, how? If not, why?

有帮助吗?

解决方案

You can't dynamically add a filter, you can however add filter that either wraps the request or just passes it along the filter chain depending on user input

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top