'JSTL error javax/servlet/jsp/jstl/core/LoopTag error when using c:forEach tomcat ver7.0 [duplicate]

Hi using
eclipse juno, dynamic web project
apache Tomcat v7.0 (which has its own jstl-1.2.1.jar) I get this error

javax.servlet.ServletException: java.lang.NoClassDefFoundError:  javax/servlet/jsp/jstl/core/LoopTag
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:343)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

when I try running this jsp code

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

<c:forEach var="test" items="a,b,c">
${test}
</c:forEach>

</body>
</html>

it seams not to be seeing the javax.servlet.jsp.jstl.core.LoopTag class that is in the jar
I have read something about filters blocking javax.servlet files

any help would be greatly appreciated


ok I think I have found the solution javax.servlet.jsp.jstl-1.2.1.jar
does not contain the javax.servlet.jsp.jstl.core classes

jstl-1.2.jar needs to be added as well



Solution 1:[1]

javax.servlet.jsp.jstl-1.2.1.jar doesn't contain the javax.servlet.jsp.jstl.core classes. Be sure to add jstl-1.2.jar as well.

Solution 2:[2]

If you are using maven, add

<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>jstl</artifactId>
  <version>1.1.2</version>
</dependency>

to your pom.xml

Solution 3:[3]

If you want to use forEach you should add two libraries to WEB-INF/lib of your project: Impl: taglibs-standard-impl-1.2.5.jar Spec: taglibs-standard-spec-1.2.5.jar

Solution 4:[4]

I imported "taglibs-standard-impl-1.2.5.jar" I downloaded from http://tomcat.apache.org/download-taglibs.cgi and I encountered the same error. I tried importing "jstl-1.2.jar" as Limited Atonement suggested before and it worked. So I compared those two jars:

  • "jstl-1.2.jar" contains 3 folders: "javax", "META-INF" and "org".
  • "taglibs-standard-impl-1.2.5.jar" contains only 2 folders: "META-INF" and "org".

So I tried swch's suggestion. I removed jstl-1.2.jar and importing both "taglibs-standard-spec-1.2.5.jar" and "taglibs-standard-impl-1.2.5.jar".

This solved the issue, because the "spec" lib contains the "javax" folder which contains the required classes.

Solution 5:[5]

I had a similar problem, using conditional tag <c:if>. I was only using taglibs-standard-impl-1.2.5.jar.

After downloading the jstl.jar from jstl.jar download page and adding it to Tomcat's installation lib directory it works.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 lmat - Reinstate Monica
Solution 2 maoyang
Solution 3 swch
Solution 4 Manawyddan
Solution 5 bcolnar