Friday, 27 July 2012

How to Add JSLT Taglibs in a Maven Project?

Here are the dependencies you need to add to your pom.xml, to include JSLT 1.1.2 taglibs in your maven project, for Tomcat:
  <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <!-- Apache Taglibs does not implement version 1.2 -->
    <version>1.1.2</version>
  </dependency>

  <dependency>
    <groupId>taglibs</groupId>
    <artifactId>standard</artifactId>
    <version>1.1.2</version>
  </dependency>

  <dependency>
    <groupId>taglibs</groupId>
    <artifactId>c</artifactId>
    <version>1.1.2</version>
    <type>tld</type>
  </dependency>

  <dependency>
    <groupId>taglibs</groupId>
    <artifactId>fmt</artifactId>
    <version>1.1.2</version>
    <type>tld</type>
  </dependency>
If you want to use JSLT version 1.2 with Tomcat, set the following dependencies:
<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>jstl</artifactId>
  <version>1.2</version>
</dependency>

<dependency>
  <groupId>org.glassfish.web</groupId>
  <artifactId>jstl-impl</artifactId>
  <version>1.2</version>
  <exclusions>
    <exclusion>
      <artifactId>servlet-api</artifactId>
      <groupId>javax.servlet</groupId>
    </exclusion>
    <exclusion>
      <artifactId>jsp-api</artifactId>
      <groupId>javax.servlet.jsp</groupId>
    </exclusion>
    <exclusion>
      <artifactId>jstl-api</artifactId>
      <groupId>javax.servlet.jsp.jstl</groupId>
    </exclusion>
  </exclusions>
</dependency>

For GlassFish:
<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>jstl</artifactId>
  <version>1.2</version>
</dependency>

What Is The Difference Between  JSTL 1.1.2 and 1.2?

For more information about the difference between JSTL version 1.1.2 and 1.2, see the answer to this StackOverflow question.

JSTL Documentation

JSLT (the Java Server Page (JSP) tag library) is a core element of web applications. It is not easy to find documentation about tags, but some useful one is still available here and here.

More Maven tips & tricks here.

2 comments: