O'Reilly logo

Grails 2: A Quick-Start Guide by Ben Klein, Dave Klein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Filters

Filters allow us to hook into, or intercept, the processing of a request. There are interceptors for before, after, and afterView. There are many uses for filters, and you can have as many filters as you need in an application. In our case, we’ll use a filter to determine whether a user is logged in when they try to access a “secure” page.

This must be sounding like a broken record (does anyone remember what that is?), but Grails makes implementing filters a snap. Create a Groovy class with a name ending in Filters, and place it in the grails-app/conf directory. In this class, define a code block called filters, and then include individual filters as if they were methods. Each filter (method) can take named parameters for controller ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required