Creating a FirstSpirit web-module: Part 1 – Why, oh why?

Community Manager
Community Manager
7 0 1,801

As I mentioned in my last post Extending FirstSpirit with modules, it's a good idea to create a FirstSpirit webapplication module if you want to use JSP/Servlets/JSP or any other Java based web technology within a website. It's especially useful if you're already using one of the FirstSpirit modules that contain a web-application. For example:

There's a dedicated section for web-applications within the project configuration dialog. If you're not familar with it, check the admin documentation (section 7.3.16 Web applications) for details and screenshots. It allows you to configure all installed web-applications for different environments (Preview/WebEdit/Staging/Production). Hitting the "Download" button will generate a war file, not just containing all jars, but a merged web.xml as well. Since it's a standard war file, it can be deployed to a servlet-container quite easily.

So what if you want to use your own taglibrary as well? Well, you could download the war, extract it, add your classes, modify the web.xml and re-pack it. Definitely something you want to avoid. Deploying the war and modifying the exploded war directory would work as well, but it's a dirty hack as well. All your changes will be lost if you re-deploy your war.

You already guessed it, creating a FirstSpirit web-application is the correct approach. That way everything will be included in the war right away. Once you have a FirstSpirit web-application, pushing your custom code into the preview/staging/production environments is just a few clicks a way.

The good news is that turning an existing taglibrary/servlet into a FirstSpirit web-applications requires very little extra effort. All you need to do is to define some metadata (create a module.xml file) and create a .fsm file – which basically is a renamed .war file. Doing so will just take a few minutes and will save you much time and hassle. Raphael already provided a great example on how to create a FirstSpirit web-application from the well know JSLT library.

So that's a start, but doesn't help you much if you're developing your own tags or servlets. You still need package the .fsm file manually. Some kind of build tool is needed to automate the process. If you're familiar with your module examples, you know that we're using Ant. So the next logical step would be to create an Ant build file that handles the creation for us. That will be the topic of my next blog post in this series.

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