| Paste number 71541: | JSP page to start embedded Clojure/swank |
| Pasted by: | avodonosov |
| When: | 1 year, 2 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+1J79 |
| Channel: | None |
| Paste contents: |
--
This JSP page is intended to start swank-clojure
in a running Java system executed in an HTTP
container like Tomcat, so that you can connect to
it from SLIME and interactively inspect, control and
modify it.
Place this JSP into your web application directory,
place clojure.jar into WEB-INF/lib.
When you open the JSP page using browser, it will
start swank listening on the port 7777. Now you
can connect to it from Emacs using M-x slime-connect
(assuming, of course, that you have swank-clojure
installed; good instructions for this may be
found at http://bc.tech.coop/blog/081023.html).
You most likely need to revise value of
the startSwankScript variable below: check
your classpath directory, port that you want
swank to listen on, swank/igonore-protocol-version
value.
Tested with Clojure svn revision 1128,
swank-clojure revision 886d66ed571fe2908de4f5714c735ab48054d587.
Anton Vodonosov, 2008-12-04
--%>
<%@page import="clojure.lang.Compiler"
import="java.io.StringReader"%>
<%!
static void startSwank() throws Exception {
// Clojure script to start swank.
// It is mostly copy/pasted from the *inferior-lisp*
// buffer, after Clojure/SLIME was started
// from Emacs. The difference from *inferrior-lisp*
// is clojure.main/with-bindings form.
final String startSwankScript =
"(add-classpath \"file:///c:/usr/unpacked/clojure/swank-clojure/\")\n" +
"(require (quote swank) (quote clojure.main))\n" +
"(clojure.main/with-bindings\n" +
" (swank/ignore-protocol-version \"2008-11-23\")\n" +
" (swank/start-server \"nul\" :encoding \"utf-8-unix\" :port 7777))\n";
Compiler.load(new StringReader(startSwankScript));
}
%>
<%
String message;
try {
startSwank();
message = "swank has been started";
} catch (Throwable e) {
message = "Exception occurred at swank startup attempt: "
+ e.getMessage()
+ ".<br/> Perhaps swank was already running.";
}
%>
<%= message %>
This paste has no annotations.