Home

Overview

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.

Usage

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.

Configuration

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:

<servlet>
  <servlet-name>FanServlet</servlet-name>
  <servlet-class>fan.servlet.FanServlet</servlet-class>
  <init-param>
    <param-name>fan.servlet.webmod</param-name>
    <param-value>mypod::MyWebMod</param-value>
  </init-param>
</servlet>

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.

Deployment

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"
    dist.run
  }
}

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

Updated

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.