I have the following code in a JSP file for the tags which is included in all of my JSP files at the top:
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/security/tags"
prefix="sec"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://www.springmodules.org/tags/commons-validator"
prefix="v"%>
<html:xhtml />
<c:set var="ctx" value="${pageContext.request.contextPath}" />
Since I recently migrated from Spring 5.X to Spring 6, I've changed the above to the following as per Jakarta Specification of 3.0 listed here:
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="jakarta.tags.core" prefix="c"%>
<%@ taglib uri="jakarta.tags.fmt" prefix="fmt"%>
<%@ taglib uri="jakarta.tags.functions" prefix="fn"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/security/tags"
prefix="sec"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://www.springmodules.org/tags/commons-validator"
prefix="v"%>
<html:xhtml />
<c:set var="ctx" value="${pageContext.request.contextPath}" />
However, I still keep on getting following error while accessing a JSP page.
[INFO] SEVERE: Servlet.service() for servlet [myapp] in context with path [/myapp] threw exception [java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/BodyTagSupport] with root cause
[INFO] java.lang.ClassNotFoundException: javax.servlet.jsp.tagext.BodyTagSupport
Here are few relevant things from my pom.xml
:
<dependency>
<groupId>jakarta.servlet.jsp.jstl</groupId>
<artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>10.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>jakarta.servlet.jsp.jstl</artifactId>
<version>3.0.1</version>
</dependency>
I'm using Tomcat 10.1.25 here to start the above app. Is there anything I need to doublecheck or doing wrong? I have looked at other posts similar to this and I seem to be satisfying what's mentioned over there.
Note: Struts is not used in the app anymore even though I have some declarations in the app and I will be removing the remnants after this issue is fixed.
If you want to comply to Jakarta Pages specification then you should remove old Struts and Display tag library definitions:
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
And, you should remove runtime and compile dependencies on them.
Remove tags usage from JSP pages such as
<html:xhtml />
Also if you are using Jakarta EE 10 then you should pick up the latest 2024-07-12 Tomcat 10.1.26 Released:
The Apache Tomcat Project is proud to announce the release of version 10.1.26 of Apache Tomcat. This release implements specifications that are part of the Jakarta EE 10 platform.