JSTL in FirstSpirit Preview- or Staging WebApps

rrichter
Crownpeak employee
Crownpeak employee
5 2 1,485

Sometimes you (or one of your friends who only works at night) want to use some of the five JSTL (JavaServer Pages Standard Tag Library) taglibs in your FirstSpirit Preview- or Staging WebApps.


If you have installed and activated the module FirstSpirit Integration, there is an easy way to include and use the JSTL.

The jstl.jar and standard.jar are included in the FirstSpirit Integration WebApp, so you can use the taglibs adding some of the following directives to
your template code that generates JSP:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

If you don't use FirstSpirit Integration but have the standard.jar and jstl.jar available, you can create a JSTL FirstSpirit WebApp module using the following directory structure:

/web.xml
/lib/jstl.jar
/lib/standard.jar
/META-INF/module.xml

with the following module.xml:

<!DOCTYPE module SYSTEM "../../server/module.dtd">
<module>
    <name>JSTL</name> <!-- name used in FirstSpirit Application -->
    <version>1.1</version>
    <description>FIRSTspirit Module for pure jstl functionality.</description>
    <components>
        <web-app scopes="global,project">
            <name>FS JSTL WebApp</name> <!-- name used in FirstSpirit WebApp-Component -->
            <description>Web component for jslt functionality.</description>
            <web-xml>web.xml</web-xml>
            <web-resources>
                <resource name="JSTL" version="1.1">lib/jstl.jar</resource>
                <resource name="JSTL-impl" version="6.0.10" minVersion="6.0.0" maxVersion="6.0.99">lib/standard.jar</resource>
            </web-resources>
        </web-app>
    </components>
</module>

and a web.xml with the following content:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app>
  <display-name>JSTL Library</display-name>
    <description>FIRSTspirit web application for JSTL functionality.</description>
</web-app>

add these files to an archive named "jstl.fsm" using the command:

jar cf jstl.fsm *

and install the .fsm on your FirstSpirit server following the instructions in the FirstSpirit Manual for Administrators, Chapter 7.3.14.

After activating the web component "FS JSTL WebApp" for the Preview-, Staging- or WebEdit-Environment of your project (or global)
you can use the JSTL taglibs the way described above.

Tested with FS4.1 FS4.2 FS4.2R2 FS4.2R4 FS5.0, FS5.2Rx

2 Comments