Search code examples
mavenjstlmaven-3

Standard way of adding JSLT 1.2.1 in a Maven Project?


What is the standard pom for adding the 1.2.1 JSTL taglib in a maven project. Any recommendations as to when/if can this be scoped as provided ? Any server peculiarities (interested in Jboss 7, Glassfish 4 and/or Tomcat 7)

EDIT: Added:

<dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>javax.servlet.jsp.jstl</artifactId>
    <version>1.2.1</version>
    <scope>provided</scope>
</dependency>

This adds:

enter image description here

Notice it transitively adds the 1.2 api.

I am using provided as I am using Jboss which should provide it: Basic question complicated solution - Tomcat to JBoss. Still this is the 1.2 api apparently

$ find . -name *jstl*.jar
./modules/javax/servlet/jstl/api/main/jboss-jstl-api_1.2_spec-1.0.2.Final.jar

(contains implementation also). So would the correct way be to add the jstl jars to the pom (not in provided scope) and mark the servlet-api (I'm on 3 anyway) as provided somehow ?


Solution

  • Ended up using :

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>
    <!-- Add the jstl-api dependency explicitly - otherwise jstl-api 1.2 is added -->
    <dependency>
        <groupId>javax.servlet.jsp.jstl</groupId>
        <artifactId>javax.servlet.jsp.jstl-api</artifactId>
        <version>1.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.web</groupId>
        <artifactId>javax.servlet.jsp.jstl</artifactId>
        <version>1.2.1</version>
        <exclusions>
             <!-- jstl-api was adding selvlet-api 2.5 and jsp-api-->
            <exclusion>
                <artifactId>jstl-api</artifactId>
                <groupId>javax.servlet.jsp.jstl</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    

    Not sure if I should add the jstl-api dependency - please comment (I would accept a more authoritative answer actually). Result:

    enter image description here

    See:

    For 1.2: