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)
[...] 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 [...]
[...] Enlace | Hola Mundo [...]
[...] 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 [...]
[...] Creating “Hello World†Web Application Using the Grails Framework [...]
[...] http://beans.seartipy.com/2008/06/15/creating-hello-world-web-application-using-the-grails-framework... [...]
PERFECT! Thanks! :)
[...] http://beans.seartipy.com/2008/06/15/creating-hello-world-web-application-using-the-grails-framework... Esta entrada fue publicada en Tutoriales y clasificada en Grails, Groovy, Java, Ubuntu. Guarda el enlace permanente. Publica un comentario o deja un trackback: URL del Trackback. Delicious « Servidor LAMP en CentOS con VirtualBox Instalar un servidor MySQL usando yum groupinstall en CentOS » [...]
This is my first successful application using Grails
Thanks for sharing =)