Install JSTL Library Step 1 − Download the binary distribution from Apache Standard Taglib and unpack the compressed file. Step 2 − To use the Standard Taglib from its Jakarta Taglibs distribution, simply copy the JAR files in the distribution's 'lib' directory to your application's webapps\ROOT\WEB-INF\lib directory.
You can dive into our beloved stackoverflow.com to find out that Tomcat doesn't include JSTL,not even in Tomcat 8, in spite that they have an implementation of the JSP Standard Tag Library (JSTL) specification, versions 1.0, 1.1 and 1.2.
org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
That URI is for JSTL 1.0, but you're actually using JSTL 1.2 which uses URIs with an additional /jsp
path (because JSTL, who invented EL expressions, was since version 1.1 integrated as part of JSP in order to share/reuse the EL logic in plain JSP too).
So, fix the taglib URI accordingly based on JSTL documentation:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
Further you need to make absolutely sure that you do not throw multiple different versioned JSTL JAR files together into the runtime classpath. This is a pretty common mistake among Tomcat users. The problem with Tomcat is that it does not offer JSTL out the box and thus you have to manually install it. This is not necessary in normal Jakarta EE servers. See also What exactly is Java EE?
In your specific case, your pom.xml basically tells you that you have jstl-1.2.jar and standard-1.1.2.jar together. This is wrong. You're basically mixing JSTL 1.2 API+impl from Oracle with JSTL 1.1 impl from Apache. You should stick to only one JSTL implementation.
In case you're already on Tomcat 10 or newer (the first Jakartified version, with jakarta.*
package instead of javax.*
package), use JSTL 2.0 via this sole dependency:
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>jakarta.servlet.jsp.jstl</artifactId>
<version>2.0.0</version>
</dependency>
Non-Maven users can achieve the same by dropping the following two physical files in /WEB-INF/lib
folder of the web application project (do absolutely not drop standard*.jar or any loose .tld files in there! remove them if necessary).
In case you're not on Tomcat 10 yet, but still on Tomcat 9 or older, use JSTL 1.2 via this sole dependency (this is compatible with Tomcat 9 / 8 / 7 / 6 / 5 but not older):
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>jakarta.servlet.jsp.jstl</artifactId>
<version>1.2.6</version>
</dependency>
Non-Maven users can achieve the same by dropping the following two physical files in /WEB-INF/lib
folder of the web application project (do absolutely not drop standard*.jar or any loose .tld files in there! remove them if necessary).
In case you're actually using a normal Jakarta EE server such as WildFly, Payara, TomEE, GlassFish, WebSphere, OpenLiberty, WebLogic, etc instead of a barebones servletcontainer such as Tomcat, Jetty, Undertow, etc, then you don't need to explicitly install JSTL at all. Normal Jakarta EE servers already provide JSTL out the box. In other words, you don't need to add JSTL to pom.xml
nor to drop any JAR/TLD files in webapp. Solely the provided
scoped Jakarta EE coordinate is sufficient:
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version><!-- 9.0.0, 8.0.0, etc depending on your server --></version>
<scope>provided</scope>
</dependency>
Further 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 5.0 (Tomcat 10) compatible example:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
version="5.0">
<!-- Config here. -->
</web-app>
And here's a Servlet 4.0 (Tomcat 9) compatible example:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<!-- Config here. -->
</web-app>
@BalusC is completely right, but If you still encounter this exception, it means that something you have done wrong. The most important information you will find is on the SO JSTL Tag Info page.
Basically this is a summary of what you need to do to deal with this exception.
Check the servlet version in web.xml: <web-app version="2.5">
Check if JSTL version is supported for this servlet version: Servlet version 2.5 uses JSTL 1.2 or Servlet version 2.4 uses JSTL 1.1
Your servlet container must have the appropriate library, or you must include it manually in your application. For example: JSTL 1.2 requires jstl-1.2.jar
What to do with Tomcat 5 or 6:
You need to include appropriate jar(s) into your WEB-INF/lib directory (it will work only for your application) or to the tomcat/lib (will work globally for all applications).
The last thing is a taglib in your jsp files. For JSTL 1.2 correct one is this:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
I found another reason for this type of error: in my case, someone set the conf/catalina.properties
setting tomcat.util.scan.StandardJarScanFilter.jarsToSkip
property to *
to avoid log warning messages, thereby skipping the necessary scan by Tomcat. Changing this back to the Tomcat default and adding an appropriate list of jars to skip (not including jstl-1.2 or spring-webmvc) solved the problem.
Add this directive to your page: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
Paste the JAR file in your WEB-INF/lib folder. This should work. (It worked for me.)
jstl-1.2.jar --> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
jstl-1.1.jar --> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
also please check for the dependency jars that you have added javax.servlet.jar
and javax.servlet.jsp.jstl-1.2.1.jar
or not in your WEB-INF/lib folder. In my case these two solved the issue.
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