I noticed an odd thing when making a servlet
(ns jms.myservlet
(import (javax.servlet.http
HttpServlet
HttpServletRequest
HttpServletResponse))
(:gen-class
:extends javax.servlet.http.HttpServlet))
(defn -init [& args]
(println "+++ init ran with args: " args))
(defn -doGet [_
#^HttpServletRequest request
#^HttpServletResponse response]
(println "+++" "in doGet")
(.. response
(getWriter)
(println (str "<html><body>hello</body></html>"))))
I've deployed the above on glassfish, and every time the page is hit
the init is run:
[#|2010-10-10T14:50:20.116-0400|INFO|glassfish3.0.1|
javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|
_ThreadID=34;_ThreadName=Thread-1;|+++ init ran with args:
(#<myservlet jms.myserv...@38f2601a> #<StandardWrapperFacade
org.apache.catalina.core.standardwrapperfac...@49d618db>)
|#]
[#|2010-10-10T14:50:20.116-0400|INFO|glassfish3.0.1|
javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|
_ThreadID=34;_ThreadName=Thread-1;|+++ in doGet
|#]
[#|2010-10-10T14:50:24.572-0400|INFO|glassfish3.0.1|
javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|
_ThreadID=34;_ThreadName=Thread-1;|+++ init ran with args:
(#<myservlet jms.myserv...@38f2601a> #<StandardWrapperFacade
org.apache.catalina.core.standardwrapperfac...@49d618db>)
|#]
[#|2010-10-10T14:50:24.573-0400|INFO|glassfish3.0.1|
javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|
_ThreadID=34;_ThreadName=Thread-1;|+++ in doGet
|#]
A servlet is supposed to be run once when the page is loaded and stick
around until destroy is called, which is the case with a Java servlet.
What am I doing wrong in implementing the servlet, so that the Clojure
one is reloaded every time it's accessed?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en