Overriding grails.views.default.codec=’html’ config back to ‘none’

To summarize the various levels at which the codec can be applied: Set Config.groovy’s grails.views.default.codec=”html” to get HTML escaping by default on all ${expressions} in the application. Then when you want to default a whole page back to none, use the directive: <%@page defaultCodec=”none” %> or <%@ defaultCodec=”none” %> To disable HTML encoding for one … Read more

Grails 2.3.0 Auto-reloading not working

It seems that in Grails 2.3 the reloading is no longer the default In Grails 2.3 the reloading agent is no longer on the build system path unless you pass the -reloading flag to the grails command: grails -reloading run-app However, you can enable forking in your buildConfig using the following configuration: forkConfig = [maxMemory: … Read more

SSL, Tomcat and Grails

How to set this up depends how you are deploying your grails app. If you are deploying to a container like tomcat, install and configure SSL as you normally would. Then just build a war file with grails war and deploy normally. For tomcat in particular, open the top level tomcat server.xml and add an … Read more

Why should grails actions be declared as methods instead of closures and what difference does it make?

The answer is here From above link Leveraging methods instead of Closure properties has some advantages: Memory efficient Allow use of stateless controllers (singleton scope) You can override actions from subclasses and call the overridden superclass method with super.actionName() Methods can be intercepted with standard proxying mechanisms, something that is complicated to do with Closures … Read more

Correct way to keep pooled connections alive (or time them out and get fresh ones) during longer inactivity for MySQL, Grails 2 app

The easiest is to configure the connection pool to specify the query to be run to test the connection before it is passed to the application: validationQuery=”select 1 as dbcp_connection_test” testOnBorrow=true This same “connection validation” query can be run on other events. I’m not sure of the defaults for these: testOnReturn=true testWhileIdle=true There are also … Read more

how to parse json using groovy

Have you tried using JsonSlurper? Example usage: def slurper = new JsonSlurper() def result = slurper.parseText(‘{“person”:{“name”:”Guillaume”,”age”:33,”pets”:[“dog”,”cat”]}}’) assert result.person.name == “Guillaume” assert result.person.age == 33 assert result.person.pets.size() == 2 assert result.person.pets[0] == “dog” assert result.person.pets[1] == “cat”