Showing posts with label jstl. Show all posts
Showing posts with label jstl. Show all posts

Monday, September 29, 2008

Tomcat 5.5 and JSTL

How to use JSTL tag library with Tomcat 5.5 and Maven:
  1. Add Maven dependencies:
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.1.2</version>
    </dependency>
    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.1.2</version>
    </dependency>
    
  2. Make sure you use at least Servlet version 2.4 in web.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
                http://java.sun.com/xml/ns/j2ee
                http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">
    
    </web-app>
    
  3. Add declaration in your JSP file:
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    
  4. Use JSTL tags:
    <c:set var="conditionValue" value="${true}"/>
    <c:if test="${conditionValue}">
    YES
    <c:if>