So lately I\'ve been looking into Clojure, and I love the language. I would like to see if I can make a small web application in it, just to challenge myself. However, I have ab
A really simple way to get started is to make a servlet that runs on Tomcat or similar, for example:
(ns servlet
((:gen-class :extends javax.servlet.http.HttpServlet))
(defn -doGet
[_ request response]
(.setContentType response "text/html")
(let w (.getWriter response)]
(.println w
(str ""
""
"Hello World! "
""
""
"Hello "
(.getParameter request "Name")
"
"
""
""))))
(defn -doPost [_ request response]
(-doGet nil request response))
then create a web.xml in your WEB-INF folder
Clojure Servlet
hello
servlet
hello
/hello
index.html
compile and package this into a war, and it'll behave just like a regular Java servlet. To deploy on Tomcat, simply drop the war in the webapps folder and start tomcat.
A detailed example is available here http://github.com/yogthos/clojure-maven-examples