Over a million developers have joined DZone.

Capturing Grails GSP Output

·
// 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);
Topics:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}