Home
For the official documentation on Groovlets please refer to the official Groovlet page.
Getting started with Groovlets
Include the Complete Groovy Jar
In your Groovy installation you should have an embeddable folder than contains a groovy-all-*.jar. You need this in your web project.
Add to the libraries in NetBeans.
Define the Groovlet Servlet
Within the web.xml configure and bind the Groovlet Servlet.
In Netbeans:
- Open the web.xml, go to the servlet tab
- Create a Groovy servlet using the class: groovy.servlet.GroovyServlet
- URL Map *.groovy to the servlet
You are now done. Groovlets are p0wning your project.
Writing your first Groovlet
Create a file hello.groovy in the web (NB:Web Pages, Eclipse: Web Content) directory.
Netbeans: create an empty file, Groovy script templates cannot be placed in an arbitrary directory.
Launch the web app and navigate to the groovy url. The screen will be blank.
By default in a servlet the System.out is bound to the servlet's response so we can just type:
print 'Hello World'
and we have created our first Groovlet. Reload the page and Hello World should appear on the served page.
The scripts are interpreted so there is no recompile and deploy cycle.