Wednesday, September 9, 2009

Creating Form in Groovlet Step 8

In your WEB-INF folder, you should create a folder called groovy. In that folder, you should put your groovy files such as groovytest.groovy.

You can create HTML tags in your groovlet along with forms. In this example, I create a text field. The groovlet creates a form along with a submit button to allow the user to submit the form. After the form is submitted, the groovlet will grab the item that was submitted and print it to the screen.

html.h1("disk free (df -h)")


html.hr()

html.h1("IP Config (ifconfig)")

html.html
{


head
{
title 'Groovy Test'
}
body
{
h1 'Groovy page called'

form(method : 'GET' , action : 'groovytest.groovy')
{
Name: input(type : 'text' , name : 'name')


input(type : 'submit', value: 'Say Hi')
}

}
}


You can paste this code in your groovytest.groovy file to test it.


Go To Step 9

0 comments: