haxx qua non

Grails and CGI

by jja on

Here's how to get CGI working in a Grails app.

Install a copy of web.xml:

grails install-templates

then edit it:


adding these elements in their appropriate sections. Some other instructions and the Tomcat encourage you to edit the main Tomcat web.xml, but that won't help you in development mode with grails run-app and also adds CGIs to all other webapps (if they're privileged).

First the servlet (there are other configurable parameters available):

    <!-- Common Gateway Interface (CGI) processing servlet -->

and the servlet-mapping:

    <!-- The mapping for the CGI Gateway servlet -->

Here's the secret part. Edit scripts/Events.groovy to make your webapp privileged:

eventConfigureTomcat = { tomcat ->
    def ctx=tomcat.host.findChild(serverContextPath)
    ctx.privileged = true

Then put your CGI script in web-app/WEB-INF/cgi/


(comments are closed)