Creating “Hello World” Web Application Using the Grails Framework
- I have covered the installation procedure of Grails framework in my previous posts:
Setting Up Development Environment For Grails on Windows Vista/XP and GNU/Linux.Just to make sure, check out again if the following environment variables are set properly on your operating system.
On Windows:





PATH should be set to something like(you can also check with ‘echo %PATH%’ on the command prompt):
c:\ruby\bin;C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin;C:\Program Files (x86)\Subversion\bin;%JAVA_HOME%\bin;%GROOVY_HOME%\bin;%GRAILS_HOME%\binOn GNU/Linux:
# echo $JAVA_HOME :: $GROOVY_HOME :: $GRAILS_HOME
/usr/lib/jvm/java-6-sun :: /home/tabrez/groovy :: /home/tabrez/grails
# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/tabrez/groovy/bin:/home/tabrez/grails/bin - Now you are all set to create Grails applications from the command line using your favourite text editor. IDE integration support for Groovy and Grails is not that great at this moment, I will write more about it in the next post. Let me just walk you through the creation of a sample Grails application from the command line.
Open the command prompt and run the following commands:
# grails create-app hello
[lot of text]
Created Grails Application at C:\Users\tabrez\grails_apps/hello
# cd hello && dir
.classpath
.project
application.properties
build.xml
grails-app
hello.launch
hello.tmproj
lib
scripts
src
test
web-app# grails create-controller hello
[lot of text]
Created ControllerTests for Hello - Open hello/grails-app/controllers/HelloController.groovy using your favourite programming editor/IDE(e.g. SciTE, Emacs, Vim) and change its content to look like this:
- Run the web application and view it in the web browser.
# grails run-app
[lot of text]
Server running. Browse to http://localhost:8080/hello
2008-06-15 15:55:51.363:/hello:INFO: GSP servlet initializedNow our application is running at the specified url. To invoke the controller that we had written earlier(Step 3), open the following url in a web browser:
http://localhost:8080/hello/hello/hello
And you should see the following output.

(If you are confused about the url: the first hello is the name of the application, the second hello is the name of the controller and the third hello is the name of the action to be invoked. In non-hello-world applications, these three will be different from each other!)
That’s it. You have created and executed your first Grails web application. Next up is IDE integration.
Resources:
For more information, refer to the following resources:
1. Grails QuickStart Guide
2. Grails Tutorials and Screencasts
3. The Definitive Guide to Grails (Amazon)
Related Posts:
Readers who viewed this page, also viewed:
- Maemo SDK VMWare Appliance 0.4 Released With Lot of Goodies
- Setting Up Development Environment For Grails on Windows Vista/XP
- “Hello, World” Web Application using Struts 2 in IntelliJ IDEA 8.0 M1
- Setting Up Development Environment For Grails on GNU/Linux
- Should I Be Developing Ajax Applications using Google Web Toolkit(GWT)?
[...] proceed to the next part of this tutorial and create an example “Hello World” web application using Grails framework to validate your Grails installation on Windows operating [...]
QuotePingback by Setting Up Development Environment For Grails on Windows Vista/XP — June 19, 2008 @ 5:01 pm
[...] Enlace | Hola Mundo [...]
QuotePingback by Getting Started with Grails « Ubuntu Life — June 23, 2008 @ 9:08 pm
[...] go to the post that explains how to create a Grails “Hello, World” web application to test if your Grails development environment is properly setup. It is for the Windows platform [...]
QuotePingback by Setting Up Development Environment For Grails on GNU/Linux — July 10, 2008 @ 2:32 pm