For what it's worth, I've included my servlet code underneath my signature. I'm still new to ABCL and this is just a quick hack, so beware, but it works for me. I auto-load the servlet, so the time for starting ABCL is not spent after the first request.
On Jan 9, 2010, at 1:24 , Blake McBride wrote:
Greetings,
I am considering using ABCL as an extension language to a Web server app I have. I know the answer to many of the questions I have in choosing the correct extension language and ABCL seems to fit the bill well. I do have some questions, however.
--
Axel.Rauschmayer@ifi.lmu.de
http://www.pst.ifi.lmu.de/~rauschma/
public class Service extends HttpServlet {
private static final long serialVersionUID = 1L;
private LispObject myFunction;
public Service() {
}
@Override
public void init(ServletConfig config) throws ServletException {
Interpreter interpreter = Interpreter.createInstance();
File file = new File(config.getServletContext().getRealPath("/"), "WEB-INF/lisp/services.lisp");
interpreter.eval("(load ""+file+"")");
org.armedbear.lisp.Package defaultPackage = Packages.findPackage("CL-USER");
this.myFunction = defaultPackage.findAccessibleSymbol("DISPATCH-JSON-RPC").getSymbolFunction();
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String content = Files.readInputStream(request.getInputStream());
LispObject result = myFunction.execute(JavaObject.getInstance(content, true));
String str = (String) result.javaInstance();
Files.writeOutputStream(str, response.getOutputStream());
response.getOutputStream().close();
}
}