Search code examples
grailsfiltertags

using g tags in controller


I am using the following statement in a filter

if(g.cookie(name:'abc'))

it prompts an error: *

groovy.lang.MissingPropertyException: No such property: g for class: com.AFilters Possible solutions: log at com.AFilters$_closure1_closure4_closure10.doCall(AFilters.groovy:77) at java.lang.Thread.run(Thread.java:679)

*

Do I have to import some class to use the statement? I have used this in controller its not creating any error


Solution

  • You can always inject grailsApplication, etc.

    But for current case, I don't see any reason to use taglib, because controller has access to request and cookies. Try:

    if (request.cookies.find { it.name == 'abc' }) {
    }