Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
; Starts an JTornado HTTP Server and a sample RequestHandler.
; Bit verbose due to compilation directives. Recommendation is to generate
; a set of macros to hide this.
(ns org.ctornadoweb
; Compiled and implements a static main method to start the server
(:import (org.jtornadoweb HttpServer)
(:gen-class :prefix "server-"))
:name org.ctornadoweb.MyHandler
:extends org.jtornadoweb.Web$RequestHandler
:prefix "do-")
(defn do-get [this]
"Handles the HTTP GET method"
(.write "hello clojure"))
(defn do-post [this]
"Handles the HTTP POST method"
(.write (.getArgument "name" "default" false)))
(defn server-main []
"main method"
(.add (org.jtornadoweb.Web$Application.) "/" org.ctornadoweb.MyHandler)
false nil false) 8089))
;use (compile 'org.ctornadoweb)

paulosuzart commented Jul 20, 2010

The server still performs super.get(), what causes an error.

kotarak commented Jul 20, 2010

Include the hyphen in the do prefix: do-.


paulosuzart commented Jul 20, 2010

oh god! worked. Thanks

I'm not a clojure fan.. but JTornado is nice!


paulosuzart commented Jul 21, 2010

Hi Felipe. We are working hard to release the first stable version of JTornado. The idea is to kill all bureaucracy for Java on the Web. We still have the plan to rearrange the webframework (primarily written for java) to better fit other VM Languages like Groovy, Scala and Clojure.

Sure.. i wrote about that last year.. but my framework works with Jetty.. but JTornado is even better because it's (even) small (than jetty) and lightweight.. and combined with something like freemarker and some lightweight persistence framework can provide a very performatic, small yet powerfull solution to put java websites with minimum effort!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment