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),

implementation 'org.eclipse.jetty:apache-jstl:9.4.15.v20190215'

implementation 'javax.servlet.jsp.jstl:javax.servlet.jsp.jstl-api:1.2.2'

implementation 'javax.servlet.jsp.jstl:jstl-api:1.2-rev-1'

implementation 'javax.servlet.jsp.jstl:jstl:1.2'

implementation 'javax.servlet:jstl:1.2'

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:


...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