2

I know that Tomcat v10.1, refers to the following SPECS :

  • Servlet 6.0
  • JSP 3.1
  • EL 5.0

So my Graddle dependencies are :

dependencies {
    compileOnly "jakarta.servlet:jakarta.servlet-api:6.0.0"
    compileOnly "jakarta.servlet.jsp:jakarta.servlet.jsp-api:3.1.0"
    compileOnly "jakarta.el:jakarta.el-api:5.0.0"
}

I suppose Tomcat already have those libraries, so I use compileOnly.

The problem is that I also need to add corresponding JSTL library, to support old JSP files that includes JSTL tag.

In my JSP files, I fix the correct JSTL tag to :

<%@ taglib prefix="c" uri="jakarta.tags.core" %>

Now regarding the import, I add those depedencies :

implementation 'jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api:3.0.0'

The problem is that the jakarta.tags.core is not recognized, I have an exception on it.

Questions :

  • The JSP spec must be 3.1. Howerver the most recent dependency on Maven is jstl-api:3.0.0 (instead of 3.1.0 that don't exist). Do that version compliant with JSP spec 3.1 ?

  • How to fix the error ?

1
  • Inclusion of JSTL for Tomcat v10.1, that comply with JSP SPEC 3.1, is not very intuitive at all. Thank you for your answer it helps. I will try ASAP the following : compile 'org.glassfish.web:jakarta.servlet.jsp.jstl:3.0.1' AND compile 'jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api:3.0.0'
    – Klun
    Commented Dec 7, 2023 at 19:01

1 Answer 1

2

In general, Tomcat version 10 does not understand classes in the javax.* package. For this reason, many applications that have javax in their code, and those built for earlier versions of Java EE, which include servlets and JSP, as well as tag libraries such as JSTL, cannot run on the new version of Tomcat 10. Therefore, it is required rewrite the code and replace all references to old libraries, and also update the application version in the descriptor, if available.

In Gradle dependencies, you also need to remove all references to javax. Depending on the dependencies, if the application uses servlet-api or jsp-api, then it must be marked as provided, because the server already has such libs, although they are loaded by another classloader, so a type conversion error may occur at runtime.

As for the JSTL of the new version, you can do the following

dependencies {
    compile 'org.glassfish.web:jakarta.servlet.jsp.jstl:3.0.1'
    compile 'jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api:3.0.0'
}
2
  • 1
    It works, with Tomcat 10.1.x, as I wish
    – Klun
    Commented Dec 8, 2023 at 9:01
  • 1
    I upgaded from Tomcat 8.5 to Tomcat 11.0 and got the same problem. After adding 'org.glassfish.web:jakarta.servlet.jsp.jstl:3.0.1' Intellj started to recognize jakarta.tags.core and application started working. Thanks!
    – vrivon
    Commented Feb 13 at 11:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.