I tried codes with jstl. The exception is
org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
I am using eclipse. I added jstl.jar
and standard.jar
. What should I give in web.xml
now? I don't know what to give in <taglib>
.
<%@ 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">
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<c:forEach var = "userName" items = "${name}">
<tr>
<td>${userName}</td>
</tr>
</c:forEach>
</body>
</html>
If you want to redistribute your tag files or implement your custom tags with tag handlers written in Java, you must declare the tags in a tag library descriptor (TLD). A tag library descriptor is an XML document that contains information about a library as a whole and about each tag contained in the library.
The JSTL XML tags are used for providing a JSP-centric way of manipulating and creating XML documents. The xml tags provide flow control, transformation etc. The url for the xml tags is http://java.sun.com/jsp/jstl/xml and prefix is x. The JSTL XML tag library has custom tags used for interacting with XML data.
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.
JSTL stands for JSP Standard Tag Library. JSTL is the standard tag library that provides tags to control the JSP page behavior. JSTL tags can be used for iteration and control statements, internationalization, SQL etc.
This can happen if you either downloaded the ancient JSTL 1.0 which has a different URI, or you placed the JAR's in the wrong place (i.e. not in /WEB-INF/lib
or anywhere in webapp's runtime classpath).
Ensure that you download the right version and put the JAR(s) in /WEB-INF/lib
. For a webapplication whose web.xml
is declared as Servlet 2.5, you need to download just JSTL 1.2 as jstl-1.2.jar. For a Servlet 2.4 webapplication, you need to download JSTL 1.1 as jstl.jar and standard.jar.
You don't need to extract the JAR's. You also don't need to modify the web.xml
as some poor online tutorials suggest. Just drop JAR(s) in runtime classpath, declare the taglib in JSP and that's it.
There is no need to make an entry of jstl.jar or standard.jar inside web.xml if the jars are kept in the lib directory inside WEB-INF. The container by default looks into the lib directory of WEB-INF
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