[armedbear-devel] Questions for use in a server

Axel Rauschmayer axel at rauschma.de
Sat Jan 9 01:31:25 UTC 2010

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 at ifi.lmu.de

public class Service extends HttpServlet {
    private static final long serialVersionUID = 1L;
    private LispObject myFunction;

    public Service() {

    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());

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/armedbear-devel/attachments/20100109/764fa0c5/attachment.html>

More information about the armedbear-devel mailing list