I have included this at the very top of my JSP page:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
I already placed the JSTL JAR file in the WEB-INF/lib
directory. But still, the JSP can't resolve the taglib. I get the below error:
Can not find the tag library descriptor for “http://java.sun.com/jsp/jstl/core”
I am using Eclipse Juno and the project structure is shown below:
Can not find the tag library descriptor for “http://java.sun.com/jsp/jstl/core”
Based on one of your previous questions you're using Tomcat 7. In that case you need JSTL 1.2. However, you've there a jstl.jar
file while JSTL 1.2 has clearly the version number included like so jstl-1.2.jar
. The sole filename jstl.jar
is typical for JSTL 1.0 and 1.1. This version requires a standard.jar
along in /WEB-INF/lib
which contains the necessary TLD files. However, in your particular case the standard.jar
is clearly missing in /WEB-INF/lib
and that's exactly the reason why the taglib URI couldn't be resolved.
To solve this you must remove the wrong JAR file, download jstl-1.2.jar and drop it in its entirety in /WEB-INF/lib
. That's all. You do not need to extract it nor to fiddle in project's Build Path.
Don't forget to remove that loose c.tld
file too. It absolutely doesn't belong there. This is indeed instructed in some poor tutorials or answers elsewhere in the Internet. This is a myth caused by a major misunderstanding and misconfiguration. There is never a need to have a loose JSTL TLD file in the classpath, also not in previous JSTL versions.
In case you're using Maven, use the below coordinate:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
You should also make sure that your web.xml
is declared conform at least Servlet 2.4 and thus not as Servlet 2.3 or older. Otherwise EL expressions inside JSTL tags would in turn fail to work. Pick the highest version matching your target container and make sure that you don't have a <!DOCTYPE>
anywhere in your web.xml
. Here's a Servlet 3.0 (Tomcat 7) compatible example:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<!-- Config here. -->
</web-app>
###See also: