<p>How do I drop a Groovlet into a Grails app?  Say, for example, in web-app/groovlet.groovy</p>

<pre>
import java.util.Date

if (session == null) {
  session = request.getSession(true);
}

if (session.counter == null) {
  session.counter = 1
}

println """
&lt;html>
    &lt;head>
        &lt;title>Groovy Servlet&lt;/title>
    &lt;/head>
    &lt;body>
Hello, ${request.remoteHost}: Counter: ${session.counter}! Date: ${new Date()}
&lt;br>
"""

</pre>

The way I understand it, groovlets are used when you have a Servlet container with Groovy scripting support,
I think in Grails you would need to move your business logic code to a
controller
and leave the view part to an HTML or a
GSP file
.
Something along those lines (meta-code from the top of my head, not tested):
grails-app/controllers/SampleController.groovy
```
```
class DateController {
    def index = {
        if (session == null) {
          session = request.getSession(true);
        }

        if (session.counter == null) {
          session.counter = 1
        }
    }
}
```
```
web-app/sample/index.gsp
```
```
<html>
    <head>
    <title>Groovy Servlet</title>
    </head>
    <body>
Hello, ${request.remoteHost}: Counter: ${session.counter}! Date: ${new Date()}
<br>
```
```
Hope that helps!