Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View gist:480886
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
; 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)
(org.jtornadoweb.Web$Application)
(org.jtornadoweb.Web$RequestHandler))
(:gen-class :prefix "server-"))
(gen-class
: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"
(.listen
(org.jtornadoweb.HttpServer.
(.add (org.jtornadoweb.Web$Application.) "/" org.ctornadoweb.MyHandler)
false nil false) 8089))
;use (compile 'org.ctornadoweb)
Owner

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

Include the hyphen in the do prefix: do-.

Owner

oh god! worked. Thanks

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

Owner

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.
Thanks.

Sure.. i wrote about that last year.. http://www.loogica.net/blog/2009/11/04/java-para-web-sem-servlets/ 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
Something went wrong with that request. Please try again.