concept Groovlets in category groovy

appears as: Groovlets
Groovy in Action, Second Edition

This is an excerpt from Manning's book Groovy in Action, Second Edition.

One obvious application where templates and markup go together is for web applications. Our next section introduces Groovlets, Groovy’s built-in support for simple yet powerful web applications.

Figure 12.4. “Hello world” as done with Groovlets
Listing 12.17. The “Hello world” Groovlet using the HTML builder
html.html{ head { title 'Groovlet Demonstrator' } body { h1 'Welcome to the World of Groovlets' } }

Groovlets are to Groovy what servlets are to Java: a basic, standardized way of writing web applications. The pure use of Groovlets is good for small and simple applications, whereas more demanding applications benefit from frameworks such as Grails (see chapter 20) or Ratpack (www.ratpack.io/).

We’re going to start with a simple “Hello world” program, which we use to demonstrate installation. We’ll briefly look at an inspection Groovlet that illustrates some of the kinds of information available to the Groovlet environment before moving on to a guessing game that lets us examine how data flows in Groovlets. Finally, we’ll rewrite the guessing game using the templating technology you saw in section 12.4.