I am using a JSP page to print an array of values. I'm trying to use JSTL <c:forEach>
for this.
<c:forEach items="${objects}" var="object">
<td>${object.name} </td>
</c:forEach>
The problem is my JSTL taglib declaration:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
The IDE shows an error on this line
Can not find the tag library descriptor.
Many of the forums point to the old Sun site to download the JSTL libraries. Now all of these links point to the Oracle home page with no link to JSTL binaries. This is leading me to believe there is a newer approach to accomplish this.
To resolve this issue:
The jstl jar
should be in your classpath. If you are using maven, add a dependency to jstl in your pom.xml
using the snippet provided here. If you are not using maven, download the jstl jar from here and deploy it into your WEB-INF/lib
.
Make sure you have the following taglib directive at the top of your jsp
:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
Just check our own JSTL wiki page for the proper download links and crystal clear installation instructions.
Put your mouse above the [jstl]
tag which you put on the question yourself until a black box shows up and click therein the info link.
Then scroll a bit down to JSTL versions information until you find download link to JSTL 1.2 (or 1.2.1).
Finally just drop exactly that file in webapp's /WEB-INF/lib
.
This way the taglib declaration must not give any errors anymore and the JSTL tags and functions should just work.
I just want to share my experience. I have same problem about jstl using maven. I resolved it by adding two dependency.
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
If you use Tomcat server I suggest you to put JSTL .jar file to the Tomcat lib folder. By doing this you will have an access to JSTL in all your web projects automatically (with taglib declaration in .jsp files of course).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With