1. Liam Staskawicz
  2. fanlet


Clone wiki

fanlet / Home


fanlet provides a simple Fantom interface to Java servlet containers. This is a new project - any feedback/suggestions are definitely welcome!

It currently depends on fantom 1.0.54, due to a couple build issues that were resolved in this release.

If you're developing on OS X live I've been, make sure to add the servlet container jars to your path, as the OS X version of Java does not include these. The same may hold for other platforms.


fanlet uses the Fantom web APIs, so it's easy to develop your app with wisp, for ease of setup, and then deploy the same code in the servlet container of your choice.

Just define a WebMod and register it as the fanlet root. It tends to be easiest for your root webmod to do routing within your app, as opposed to configuring routes in the servlet environment.


Specify the class of your root WebMod in the web.xml file that goes in the WAR that you deploy to your servlet container. There should be an entry that looks something like:


Basically everything above should be in your web.xml verbatim, except for mypod::MyWebMod which you should modify to suit your case. The FanServlet will create an instance of your WebMod, and adapt requests and responses between it and the servlet environment.


I've found it to be quite convenient to use the Fantom JarDist to create a single jar containing my app and required pods, which can be dropped into the servlet environment. A sample build script to create the deployment jar might look something like:

class Build : BuildScript
  @Target { help = "build my app as a single JAR dist" }
  Void dist()
    dist := JarDist(this)
    dist.outFile = `./war/WEB-INF/lib/myapp_deploy.jar`.toFile.normalize
    dist.podNames = Str["myapp_pod", "servlet", "web", "webmod", "util", "inet", "concurrent"]
    dist.mainMethod = "myapp::Main.main"

Note that you'll need to define an empty Main routine in this case, since all jars need one.