Creating a FirstSpirit web-module: Part 2 – Building the module

Community Manager
Community Manager
5 5 1,527

Now that you're convienced that creating a web-application module is a good idea, let's see how you can do so. I've added a complete web-application module to our source code examples.  The module contains a simple servlet and and even simpler taglibrary to showcase the FirstSpirit specific parts.

Getting started
Build the module
  1. Grab and extract the source code examples.
  2. Grab the fs-access.jar (located at /data/fslib) and the fs-client.jar (/web/fs4root/clientjar) from your FirstSpirit server. Copy them to /examples/FS_V4_mod/lib. These two libraries are needed to compile the examples. You'll also need a servlet-api.jar and a jsp-api.jar. They're are shipped with every Tomcat/Glassfish/Jetty installation. Your IDE may ship them as well.
  3. Edit the (setenv.bat if you're on windows) and adjust the path to your JDK.
  4. Execute or setenv.bat to configure the build environment.
  5. Perform a "ant assemble-all" to build all modules, including the web-application example. If you just want to build the web-application example, run "ant assemble-fsm" within the examples/FS_V4_mod/webapp/ directory.
Install the module on a FirstSpirit server
  1. Locate the fsm file under examples/FS_V4_mod/webapp/target/fsm
  2. Install the newly created fsm archive in the 'Server and Project Configuration', Server -> Server properties -> Modules -> Installserver_properties.png
  3. Edit your project, go to the "web components" section and add the module to an environment. Refer to the admin documentation (section 7.3.16 Web applications) for details. Add it at least to the Preview and Production environment.project_web_components.png

Please note that you're able to edit the web.xml, which shipped with the module, by clicking the "web.xml" button. That feature is provided out of the box. Clicking on the "Confgure" button will show you a simple, Swing based, configuration screen.

Verify it's working
  1. Switch to the "Preview" environment tab and click on the "Update" button at the top. This will deploy the web-application to your internal Jetty.project_web_components_update.png
  2. Create a new page template (or modify an existing one) to include the new JSP-Tag.
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="t" uri="HelloWorld"  %>
  <head><title>Simple jsp page</title></head>
   <p><t:greeter name="Joe"/></p>
   <p><t:greeter name="${param['name']}"/></p>
   <p><t:greeter /></p>

Every working? Great, so let's have a closer look at our webapplication:

WebApp Features

The taglib implements one simple "hello world" tag. Nothing fancy here.


The servlet is nearly as simple as the taglib. It implements a very simple hit counter ("This servlet has been called x times."). The two configuration options are controlled via a java properties file named "".

Execute the servlet by calling http://YOURHOST/YOURAPP/hello or http://YOURHOST/YOURAPP/hello?name=John


You already know, we're using  Ant as a build tool. The build.xml contains all normal ant tasks,  necessary to build a Java based project (compile, create jars). The task to create our module (.fsm file) is called "assemble-fsm". As I  mentioned in my previous blog post, a fsm file isn't much more than a  renamed jar file, containing a module.xml.

Here's the file structure of the generated fsm file:


This file contains the configuration options for our servlet.



Defines our tag

<?xml version="1.0" encoding="UTF-8"?>
<taglib version="2.0" xmlns="" xmlns:xsi="" xsi:schemaLocation=" web-jsptaglibrary_2_0.xsd">


Define our servlet and it's mapping

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
         xsi:schemaLocation="" >


Lib directory
  • The webapp-example-0.0.1_422.jar contains all FirstSpirit specific classes, which are necessary to install/configure the module.
  • The webapp-example-0.0.1_422-webapp.jar contains the servlet and taglibrary.


Contains all metadata for our module.

<!DOCTYPE module SYSTEM "../lib/module.dtd">
    <name>FirstSpirit WebApp Example Module</name>
    <description>FirstSpirit WebApp Example Module</description>
    <vendor>e-Spirit AG</vendor>
            <name>FirstSpirit WebApp Example Module</name>
            <description>Web component of FIRSTspirit integration.</description>

I'll cover the module.xml as well as all referenced classes in the next installment of this series.

Next part: Creating a FirstSpirit web-module: Part 3 – Understanding the module