0

When navigating to a JSP page that uses JSTL, I get an error:

Message org.apache.jasper.JasperException: Failed to load or instantiate TagLibraryValidator class: [org.apache.taglibs.standard.tlv.JstlCoreTLV]

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

dependency in pom.xml:

<dependency>
   <groupId>jstl</groupId>
   <artifactId>jstl</artifactId>
   <version>1.2</version>
</dependency>

(<groupId> javax.servlet </groupId> also doesn't work)

JSP page:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Error</title>
    <style><%@ include file="/frontend/style/style.css"%></style>
</head>
<body>

<section class="error">
    <div class="error__img"><img src="${pageContext.request.contextPath}/frontend/images/error.png" alt=""></div>
    <p class='error__sorry'><c:out value="We are very sorry"/></p>
    <form action="hotel" method="post" class="error__back">
        <button type="submit" name="command" value="toMainPage">Back to main page</button>
    </form>
</section>
</body>
</html>

Project structure, if important:

structure

Topinambur
  • 55
  • 5
  • Based on the information provided so far, that can happen if your Tomcat is manually modified to include JSTL 1.1 while the webapp ships along with solely the JSTL 1.2 as visible in the "project structure" image. Solution would be to throw away Tomcat and unzip a new one and make sure you don't modify it. – BalusC Jun 09 '21 at 23:53
  • @BalusC, did not help. I have also `java.lang.ClassCastException: class org.apache.taglibs.standard.tlv.JstlCoreTLV cannot be cast to class jakarta.servlet.jsp.tagext.TagLibraryValidator (org.apache.taglibs.standard.tlv.JstlCoreTLV is in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @6165a875; jakarta.servlet.jsp.tagext.TagLibraryValidator is in unnamed module of loader java.net.URLClassLoader @4eb7f003)` error – Topinambur Jun 10 '21 at 06:28
  • Ah you're using Tomcat 10. You should be using JSTL 2.0 instead. See abovelinked duplicate. – BalusC Jun 10 '21 at 09:15

0 Answers0