web.xml for jstl [duplicate]
Asked Answered
M

4

6

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>
Moisture answered 14/12, 2010 at 9:41 Comment(1)
Which servlet container are you using?Migration
S
6

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.

Savor answered 17/12, 2010 at 18:29 Comment(0)
B
2

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

Bruns answered 4/5, 2012 at 4:51 Comment(0)
F
0

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.

Fara answered 17/12, 2010 at 17:0 Comment(0)
B
0

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.

Bratcher answered 26/5 at 1:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.