Confounding the frequent issues around standing up a JSTL-capable JSP app is the plethora of similarly-named JSTL libraries. Expressed in Gradle notation (though this problem is not Gradle-specific),

// https://bintray.com/bintray/jcenter/org.eclipse.jetty%3Aapache-jstl
implementation 'org.eclipse.jetty:apache-jstl:9.4.15.v20190215'

// https://bintray.com/bintray/jcenter/javax.servlet.jsp.jstl%3Ajavax.servlet.jsp.jstl-api
implementation 'javax.servlet.jsp.jstl:javax.servlet.jsp.jstl-api:1.2.2'

// https://bintray.com/bintray/jcenter/javax.servlet.jsp.jstl%3Ajstl-api
implementation 'javax.servlet.jsp.jstl:jstl-api:1.2-rev-1'

// https://bintray.com/bintray/jcenter/javax.servlet.jsp.jstl%3Ajstl
implementation 'javax.servlet.jsp.jstl:jstl:1.2'

// https://bintray.com/bintray/jcenter/javax.servlet%3Ajstl
implementation 'javax.servlet:jstl:1.2'

// https://bintray.com/bintray/jcenter/jstl%3Ajstl
implementation 'jstl:jstl:1.2'

This is a perfect minefield for a newcomer to JEE. The wiki touches on three of them, identifying jstl:jstl and javax.servlet.jsp.jstl:jstl as bad and recommending javax.servlet:jstl, but it does not mention the first three.

On my installation of Jetty 9, I only see the following jars with "jstl" in the name:

/usr/share/java/jetty9-apache-jstl.jar
/usr/share/java/jetty9-apache-jstl-9.4.15.v20190215.jar
/usr/share/maven-repo/org/eclipse/jetty/apache-jstl/9.4.15.v20190215/apache-jstl-9.4.15.v20190215.jar
/usr/share/maven-repo/org/eclipse/jetty/apache-jstl/debian/apache-jstl-debian.jar

...and yet JSTL still somehow works when a WAR is deployed to it that has a reference to org.eclipse.jetty:apache-jstl:9.4.15.v20190215 and no reference of any kind to javax.servlet:jstl:1.2.

When I reduce my dependencies to

dependencies {
    // Bundled in Ubuntu's libjetty9-java so not embedded
    compileOnly 'org.eclipse.jetty:apache-jsp:9.4.15.v20190215'

    // todo - This should not need to be 'implementation'
    // when hosted in Jetty, this alone is enough to support JSTL
    // in Gretty, this isn't enough
    implementation 'org.eclipse.jetty:apache-jstl:9.4.15.v20190215'
}

gradlew dependencies shows:

runtimeClasspath - Runtime classpath of source set 'main'.
+--- javax.servlet:javax.servlet-api:3.1.0
+--- javax.websocket:javax.websocket-api:1.0
\--- org.eclipse.jetty:apache-jstl:9.4.15.v20190215
     +--- org.apache.taglibs:taglibs-standard-spec:1.2.5
     \--- org.apache.taglibs:taglibs-standard-impl:1.2.5

Looking into that Apache JAR reveals that they did some repackaging - taglibs-standard-spec-1.2.5.jar actually contains the classes for javax.servlet.jsp.jstl.

What's going on here? Why is the recommended javax.servlet:jstl not needed there? And more broadly, what is the exact difference between those six libraries listed?

0 Answers