Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails GSP Compilation?

When you compile a grails war, I understand that the .groovy code is compiled in to bytecode class files, but I don't understand how the container (say, tomcat), knows how to compile the GSPs when they are requested. Do the containers understand GSP? Does the fact that grails is installed on the server hook into the containers?

Also, when the GSP is used for the first time, it is compiled then on demand and only once. Is this correct? Thanks.

like image 696
skaz Avatar asked Jul 20 '11 14:07

skaz


2 Answers

Do the containers understand GSP?

The GSPs are actually compiled into class files when the war is built, and not at runtime by tomcat - if you unzip the war file, you can look at what it does (look at the unzipped WEB-INF/classes directory):

...
gsp_appname_controllerNameviewName_gsp.class
gsp_appname_controllerNameanotherViewName_gsp.class
...

The container doesn't need to do anything at runtime, since everything's pre-compiled.

Does the fact that grails is installed on the server hook into the containers?

It does not; everything needed for the application to run is included in the war, so grails being installed on the container's server makes no difference.

like image 109
Rob Hruska Avatar answered Sep 21 '22 12:09

Rob Hruska


Ok, so just found this on the mailing list:

Since grails 1.2 the gsps are pre compiled when generating the war file.

like image 24
Gregg Avatar answered Sep 21 '22 12:09

Gregg