Groovlets:

runjetty.groovy:

--
import org.mortbay.jetty.Server
import org.mortbay.jetty.servlet.*
import groovy.servlet.*

@Grab(group='org.mortbay.jetty', module='jetty-embedded', version='6.1.14')
def startJetty() {
    def jetty = new Server(9090)

    def context = new Context(jetty, '/', Context.SESSIONS)  // Allow sessions.
    context.resourceBase = '.'  // Look in current dir for Groovy scripts.
    context.addServlet(GroovyServlet, '*.groovy')  // All files ending
with .groovy will be served.
    context.setAttribute('version', '1.0')  // Set an context attribute.

    jetty.start()
}

println "Starting Jetty, press Ctrl+C to stop."
startJetty()
--

runjetty.grovy:
--
def method = request.method

if (!session) {
    session = request.getSession(true)
}

if (!session.groovlet) {
    session.groovlet = 'Groovlets rock!'
}

html.html {
    head {
        title 'Groovlet info'
    }
    body {
        h1 'General info'
        ul {
            li "Method: ${method}"
            li "RequestURI: ${request.requestURI}"
            li "session.groovlet: ${session.groovlet}"
            li "application.version: ${context.version}"
        }

        h1 'Headers'
        ul {
            headers.each {
                li "${it.key} = ${it.value}"
            }
        }
    }
}
--


Run as:

groovy runjetty.groovy

and go to: http://localhost:9090/servlet.groovy, and you get:


General info

Method: GET
RequestURI: /servlet.groovy
session.groovlet: Groovlets rock!
application.version: 1.0
Headers

Host = localhost:9080
Connection = keep-alive
User-Agent = Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US)
AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204
Safari/534.16
Accept = 
application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Encoding = gzip,deflate,sdch
Accept-Language = fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
Accept-Charset = ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie = crucibleprefs1="D%3D1296634090117%3Baec%3DY%3Bslp%3Dt%3Basv%3Dfe";
nes_popin_language=ok;
s_stc=%5B%5B%27ref%253Alocalhost%253A8080%27%2C%271297266460481%27%5D%5D;
s_schan=%5B%5B%27Referrers%27%2C%271297266460482%27%5D%5D;
s_skw=%5B%5B%27%255BReferrers%255D%27%2C%271297266460483%27%5D%5D

No XML there.

Matthew.

2011/4/13 Ricky Clarkson <ricky.clark...@gmail.com>:
> Please show me how to create and deploy a web application, using any JVM
> technology at all, without generating or writing any XML.
> I'm not only asking to be awkward, I genuinely would like to see an answer
> to that.
> --
> Skype: ricky_clarkson
> UK phone (forwards to Skype): 0161 408 5260
> On Wed, Apr 13, 2011 at 10:52 AM, Mark Volkmann <r.mark.volkm...@gmail.com>
> wrote:
>>
>> On one of Gavin's slides he says:
>>
>> "Java is joined at the hip with XML, and this hurts almost every Java
>> developer almost every day"
>>
>> Really? In what way is Java joined at the hip with XML? Just because
>> some people use Ant and some people using XML for Spring
>> configuration? I don't see how this is related to Java the language.
>> Does it really hurt most Java developers most days? I really doubt
>> that. I think most Java developers go days on end without seeing any
>> XML.
>>
>> There are many valid reasons to dislike Java, but XML is not one of them.
>>
>> On Wed, Apr 13, 2011 at 8:02 AM, Serge Boulay <serge.bou...@gmail.com>
>> wrote:
>> > Another language in the works. Let the Scala vs "Ceylon project" wars
>> > begin.
>> >
>> >
>> > http://devstonez.wordpress.com/2011/04/13/introducing-the-ceylon-project-gavin-king-presentation-at-qcon-beijing-2011/
>> >
>> > http://blog.talawah.net/2011/04/gavin-king-unviels-red-hats-top-secret.html
>>
>> --
>> R. Mark Volkmann
>> Object Computing, Inc.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "The Java Posse" group.
>> To post to this group, send email to javaposse@googlegroups.com.
>> To unsubscribe from this group, send email to
>> javaposse+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/javaposse?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "The Java Posse" group.
> To post to this group, send email to javaposse@googlegroups.com.
> To unsubscribe from this group, send email to
> javaposse+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/javaposse?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to javaposse@googlegroups.com.
To unsubscribe from this group, send email to 
javaposse+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to