Reputation: 6707
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>
Upvotes: 6
Views: 11575
Reputation: 7171
In my case, project had similar exception, trying for several hours, I find in pom.xml, <packaging>jar</packaging>
had problem, change to war(file format)
fix.
Upvotes: 0
Reputation: 489
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
Upvotes: 2
Reputation: 1108722
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.
Upvotes: 6
Reputation: 9767
You shouldn't have to add the taglib elements to web.xml. The standard & jstl jars are interrogated via the service mechanism in the container.
Make sure the jars are exported with the web-app and located under WEB-INF/lib and you should be fine.
Upvotes: 0