Skip to content
A Leiningen 2 plugin to work with servlet-based webapps
Clojure ColdFusion Java PHP
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


A Leiningen 2 plugin to work with servlet-based webapps.

As of version 0.1.0, the only activity it supports is to start a specified servlet container (Jetty and Tomcat are supported) with configured webapps.

NOTE: This plugin is only to work with servlets based web apps. For idiomatic web development using Clojure you should consider lein-ring and ring.


It takes multi-line configuration in project.clj to use lein-servlet. For example, a minimal configuration might look like this:

:plugins [[lein-servlet "0.1.0"]]
:servlet {:deps    [[lein-servlet/adapter-jetty7 "0.1.0"]]
          :webapps {"/" {:classes {"/*" com.myapp.WebServlet}
                         :public  "public"}}}

Given the servlet class exists in classpath and directory public exists too, when you run lein servlet run it starts the Jetty servlet container with the webapp at http://localhost:3000/

Creating a project via templates

In many cases you may be using lein-servlet templates that are actually project skeletons of several types.

You do not need to have any plugin installed to create a template. Unless you already have a version of lein-servlet/lein-template, the following commands automatically download the latest version for use.

The command to create lein-servlet project skeletons is:

lein new lein-servlet [flavor] project-name

Both flavor and project-name are placeholders for the actual names to be used. Note that flavor is optional and indicates a project type. Currently the flavor can be either of quercus, railo and struts. See examples:

$ lein new lein-servlet foo          # creates a simple Clojure/servlet webapp
$ lein new lein-servlet quercus foo  # " a Clojure/PHP webapp that uses Quercus
$ lein new lein-servlet railo foo    # " a Clojure/CFML webapp that uses Railo
$ lein new lein-servlet struts foo   # " a Clojure/Java webapp that uses Struts1

Regular configuration

The recommended use of lein-servlet is as a project-level plugin. Put [lein-servlet "0.1.0"] into the :plugins vector of your project.clj.

If you must use this as a user-level plugin, put [lein-servlet "0.1.0"] into the :plugins vector of your :user profile, or if you are on Leiningen 1.x do lein1 plugin install lein-servlet 0.1.0.

For a detail list of all possible configuration options please check the file sample.project.clj.

Command-line usage

To view the configured servlet engine:

$ lein servlet engine

To start all configured webapps using the configured servlet engine:

$ lein servlet run  # opens server homepage in browser

Getting in touch

Leiningen mailing list:


E-mail: kumar.shantanu(at)


Copyright © 2012 Shantanu Kumar

Distributed under the Eclipse Public License, the same as Clojure.

Something went wrong with that request. Please try again.