JavaBeat
Search JavaBeat

JAVABEAT
home
articles
tips
code junction
QnA
Books
forums
ARTICLE TOPICS
All Articles
Java 5.0
Java 6.0
EJB 3.0
JCA
Struts
JSF
Spring
Groovy
JBoss Seam
Hibernate
Eclipse
JavaFx
Google Guice
J2ME
GWT
WebServices
AJAX
ARCHIVE
2007 | 12 11 10 09 08 07 06 05 04 03
2008 | 04 03 02 01
CERTIFICATION KITS
350 SCJP 1.5 Mock Exams
400 SCJP 1.6 Mock Exams
300 SCWCD 5.0 Mock Exams
300 SCBCD 5.0 Mock Exams
Enter email address:

Latest JavaBeat Articles Delivered by FeedBurner
Sponsors
Java Jobs Get Firefox 2! Linux Reviews Get Ubuntu 8.04  

PacktPub Publication Java Books
Pages : 1 2

Web Development in Groovy using Groovlets

Author : Raja
Date : Sun Dec 9th, 2007
Topic : groovy  
Title : Web Development in Groovy using Groovlets
Publisher : Raja

1) Introduction

In this article, we will learn about how to achieve Web Development using Groovy. Groovy is a scripting language and it has components called Groovlets which sit on top of a Web Server for handling HTTP Requests and Responses similar to Java Servlets. This article will provide an overview about Groovlets in the first section and will present several code snippets that will help in simplifying the usage of Groovlets in the subsequent sections. Remember, this is not an introductory article on Groovy and first-time readers are strongly advised to have a look over the Introductory article on Groovy .

2) Groovlets

Before getting into Groovlets, let us look into the basics of a typical Java Web Application. Usually a Web Server will host one or more Web Applications and the Client's Requests are handled by Components called Java Servlets which usually sit on top of the Web Server. A Servlet continue to live within the Web Server's address space and its life-time will be controlled only by the Web Server. One of the major responsibilities of a Web Server is to match a client request to a particular Servlet in an Application. Typically, this is done in the Application's configuration file, usually web.xml file.

So a Java Servlet can be considered as an extension point which provides some useful services to a Client. The Web Server wraps the Client request and passes a Http Request object to the Servlet. The Servlet retrieves various inputs from the Client and executes some actions accordingly. A Servlet is written in pure Java code and one can see a mix of Java Business logic as well as Html UI Generation in a Servlet.

Now, let us see the Java Servlet's counterpart, Groovlets. Groovlets, or Groovy Pages that end with .groovy extension are processed by Groovy Engine which sits on top of a Web Server. Typically, a Groovy Engine is nothing but a Groovy Servlet. When a client requests for a Groovy page for the very first time, the Groovy Servlet will be invoked (we will configure this in the Application's descriptor file) and parses the page to convert into a Java class or a Java Servlet. The Java Servlet is then compiled and an instance of the class will be created by the Web Server. Groovlets are much suitable only for simpler or small Web Applications. Compared to Java Servlets, coding in Groovy will be much simpler.

In the next few sections, we will see how to develop Groovlets or Groovy pages.

 
Pages : 1 2
 

Sponsors
Webmaster Hosting Forum
Java Jobs
Latest in DLinks
http://javawave.blogspot.com/2008/04/quartz-job-scheduler-part-ii-example.html
Quartz Job Scheduler -- Part 1 (Setting up development project in Netbeans 6.1 beta)
Flex Messaging with BEA Workshop Studio
SOA and Virtualization: How do They Fit Together?
Introduction to Enterprise Portals - Why they Benefit IT and the Business
BEA WebLogic Operations Control: Application Virtualization for Enterprise Java
Best Practices for Building Production Quality EAR Files
BEA's SOA Reference Architecture - A Foundation for Business Agility
Blueprint for Successful SOA Integration
Guardian - What a tool!

JavaBeat Media (2004-2008), India
javabeat home | About Us
our network : opensource softwares
Copyright © 2007 JavaBeat