Can not find the tag library descriptor for “http://java.sun.com/jsp/jstl/core” [duplicate]
Asked Answered
L

18

64

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:

enter image description here

Linguistics answered 8/11, 2012 at 9:10 Comment(2)
add the jar file to your classpathFlaggy
Are you talking about eclipse not being able to resolve the taglib, or tomcat?Gabar
W
125

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:

Westing answered 9/11, 2012 at 12:2 Comment(1)
just adding jstl-1.2.jar jar solved in my case. ThanksPhyletic
S
19

I had same problem and despite having jstl

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

I had to add 'standard' as well:

<dependency>
    <groupId>taglibs</groupId>
    <artifactId>standard</artifactId>
    <version>1.1.2</version>
</dependency>

Also, as mentioned in previous post:

Southing answered 18/4, 2017 at 19:5 Comment(0)
G
12

The URI depends on the version of JSTL you are using. For Version 1.0 use:

http://java.sun.com/jstl/core

and for 1.1 (and later), you need to use:

http://java.sun.com/jsp/jstl/core
Gabar answered 8/11, 2012 at 9:13 Comment(0)
I
6

If you are using maven your pom's <dependencies> tag should look like:

<dependencies>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp.jstl</groupId>
        <artifactId>javax.servlet.jsp.jstl-api</artifactId>
        <version>1.2.1</version>
    </dependency>
    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.1.2</version>
    </dependency>
</dependencies>

It works for me.

Immense answered 10/12, 2015 at 13:52 Comment(1)
I have been looking at this issue for years off and on, with all the correct setup which is documented everywhere. Adding taglibs as shown above from mvnrepository.com/artifact/org.apache.taglibs/… resolved it.Fucus
B
2

Downloading jstl-1.2.jar instead of jstl.jar solves the problem

Blenheim answered 6/6, 2018 at 5:9 Comment(0)
T
2

This works as well:

<dependency>
    <scope>compile</scope>
    <groupId>javax.servlet.jsp.jstl</groupId>
    <artifactId>jstl-api</artifactId>
    <version>1.2</version>
</dependency>

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

so used jstl 1.2 instead of standard.jar together with jstl-api 1.2

Topeka answered 6/3, 2019 at 15:35 Comment(0)
C
1

Make sure that both the below jars are present in the build path:

  1. standard-1.1.2.jar
  2. jstl-api-1.2.jar

Maven Dependencies are:

<dependency>
    <groupId>javax.servlet.jsp.jstl</groupId>
    <artifactId>jstl-api</artifactId>
    <version>$1.2</version>
</dependency>

<dependency>
   <groupId>taglibs</groupId>
   <artifactId>standard</artifactId>
   <version>1.1.2</version>
</dependency
Combustible answered 16/2, 2018 at 6:25 Comment(1)
unreal when the negative vote, actually is the only one that solves the problemBulwark
C
0

You need to configure this in web.xml as well:

<taglib>
    <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
    <taglib-location>/WEB-INF/lib/c.tld</taglib-location>
</taglib>
Carlina answered 8/11, 2012 at 9:50 Comment(3)
Whether you need to do this depends on the JSP version in use. This is only neccessary for version smaller than 2.0. Tomcat uses JSP 2.0 since 5.5. So under normal circumstances, this should not be needed.Gabar
Thanks @nfechner..I was not aware of this.Carlina
This bad myth is only true when you used the wrong JSTL version for the JSP version. You should instead rather have downloaded and used the right JSTL version for the JSP version used. You should absolutely not extract the TLD file from the JAR and clutter the classpath and web.xml with it. See also stackoverflow.com/tags/jstl/infoWesting
M
0

Well, I have read this post and seems it is not good enough to fix this issue.

Spring based application on the tomcat 8 will not work.

Here is the solution

Step 1 ⇒ Add the following dependency in your pom.xml

<!-- JSTL Support -->

     <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
</dependency>
<dependency>
    <groupId>javax.servlet.jsp</groupId>
    <artifactId>javax.servlet.jsp-api</artifactId>
    <version>2.3.1</version>
</dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
</dependency>

Step 2 ⇒ Add All following two statement in your JSP page, ensure that you are using isELIgnored="false" attribute in <%@ page %> tag

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" isELIgnored="false" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

Step 3 ⇒ Remove all the other configuration that you have done till now in web.xml or anywhere else :)

Step 4 ⇒ Clean the Tomcat and restart Tomcat.

Side Note ⇒ Actually, JSTL will work with only 3.x Servlet specifications on Tomcat 8.

[http://www.kriblog.com/j2ee/jsp/jstl-with-spring-4-on-tomcat-8.html]
Malm answered 21/2, 2016 at 15:6 Comment(1)
Servlet and JSP APIs don't belong in webapp. They are already provided by Tomcat itself.Westing
H
0

Add the jstl and standard jar files to your library.

Halflength answered 4/5, 2017 at 8:24 Comment(0)
B
0

add the maven dependencies:

<dependency>
  <groupId>jstl</groupId>
  <artifactId>jstl</artifactId>
  <version>1.2</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>taglibs</groupId>
  <artifactId>standard</artifactId>
  <version>1.1.2</version>
  <scope>compile</scope>
</dependency>
Best answered 11/7, 2017 at 12:17 Comment(0)
S
0

Simply download javax.servlet.jsp.jstl.jar and add to your build path and WEB-INF/lib if you simply developing dynamic web application.

When you develop dynamic web application using maven then add javax.servlet.jsp.jstl dependency in pom file.

Shadrach answered 30/11, 2017 at 4:50 Comment(0)
B
0

This is a very common error while working on JSTL.

To solve this error simply:

  1. Download jstl-1.1.2.jar and standard-1.1.2.jar
  2. And then just paste them in lib folder under WEB-INF of your Dynamic Web App project.
Bookout answered 4/1, 2020 at 15:6 Comment(1)
Jstl jar version depends on the version of the Tomcat serverHeterozygous
C
0
To resolve the issue in jsp we have to use the dependency below in the pom file. If you dont use maven then download the dependency jar and add it to your WEB-INF directory.
<dependency>
    <groupId>jstl</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>taglibs</groupId>
    <artifactId>standard</artifactId>
    <version>1.1.2</version>
    <scope>compile</scope>
</dependency>
Cleora answered 23/1, 2020 at 19:7 Comment(1)
The standard dependency is not needed at all. You're basically mixing JSTL 1.2 API+impl from Oracle with JSTL 1.1 impl from Apache here. This makes no sense.Westing
D
0

I got the same error message (Eclipse Enterprise 2020-06, Tomcat 8.5, dynamic web project), even after I downloaded version 1.2.5 of the jst library (here), dropped it into the "WEB-INF/lib" folder and added <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> to the very top of the jsp file.

Using version 1.2 (here) instead fixed it.

Deepsea answered 20/7, 2020 at 12:23 Comment(0)
D
0

I found sometimes even with the right dependencies, Eclipse can still raise the error. Below are the methods I used to make Eclipse update:

Method 1 : Copy paste jsp.

error happens for jsp in deeper layer

I also find a strange situation that when the same jsp is deeper in my directory, its taglibs cannot be found. However, when it is under /webapp/ it has no issue.

I tried maven clean, maven build, project clean, all cannot resolve the problem.

I resolved it by deleting the jsp with error can copy the correct jsp from outer folder to inner folder again. Then the taglibs can be recognized.

jsp error resolved after copy paste jsp in outer folder

Therefore, I think it could be a bug by Eclipse itself.

My dependencies are like

    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.1.2</version>
    </dependency>

Method 2 : change version of jstl and change back

try change version of jstl, then maven clean and maven update, then change back the version and maven clean again.

Decarlo answered 22/4, 2021 at 6:54 Comment(1)
The standard dependency is not needed at all. You're basically mixing JSTL 1.2 API+impl from Oracle with JSTL 1.1 impl from Apache here. This makes no sense.Westing
L
0

In case you are using IntelliJ, download jstl-1.2.jar and standard-1.1.2.jar. Then add them into your Global Libraries. This worked perfectly for me.

Levitation answered 3/8, 2022 at 11:45 Comment(2)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Primarily
The standard dependency is not needed at all. You're basically mixing JSTL 1.2 API+impl from Oracle with JSTL 1.1 impl from Apache here. This makes no sense.Westing
U
-1

What worked for me (I use Java 8 and Tomcat 9 in Eclipse 2019):

pom.xml

    <!-- jstl -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp.jstl</groupId>
        <artifactId>javax.servlet.jsp.jstl-api</artifactId>
        <version>1.2.1</version>
    </dependency>
    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.1.2</version>
    </dependency>

.jsp file

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
Urethroscope answered 9/4, 2019 at 0:16 Comment(1)
The standard dependency is not needed at all. You're basically mixing JSTL 1.2 API+impl from Oracle with JSTL 1.1 impl from Apache here. This makes no sense.Westing

© 2022 - 2024 — McMap. All rights reserved.