DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Capturing Grails GSP Output

04.22.2007
| 3782 views |
  • submit to reddit
        // this creates the template manually and captures the output of the GSP in a StringWriter called "writer"

def binding = [ dude : Dude.get( params.id ) ];  
def writer = new StringWriter();
def template = grailsAttributes.getPagesTemplateEngine().createTemplate("/WEB-INF/grails-app/views/dude/show.gsp", servletContext, request, response);
template.make(binding).writeTo(writer);
println(writer);