I'm developing an application (on Eclipse) with some jsp pages on Tomcat.
I've already downloaded the JSTL jars
(http://jstl.java.net/download.html)
and added them to web-inf/lib and to my build path.
However, when I access the page, I always get:
SEVERE: Servlet.service() for servlet [jsp] in context with path [/AccessControl2] threw exception [/ADAccess.jsp (line: 16, column: 1) No tag "foreach" defined in tag library imported with prefix "c"] with root cause
org.apache.jasper.JasperException: /ADAccess.jsp (line: 16, column: 1) No tag "foreach" defined in tag library imported with prefix "c"
Here is my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
As for my JSP, this is how I am doing it:
<%@ 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 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<BODY>
<script type="text/javascript" src="saveOptions.js"></script>
<FORM METHOD=POST ACTION="SaveADAccess.jsp">
<jsp:useBean id="obj" class="nbsi.config.access.ADGroupListBean" scope="page"/>
<select name="withoutAccess" size="5">
<c:foreach var="item" items="${obj.withoutAccess}">
<option>${item}</option>
</c:foreach>
</select>
<select name="withAccess" size="5">
</select>
<P>
<INPUT TYPE=SUBMIT>
<input type="button" onClick="removeOptions(withoutAccess,withAccess)"value="Give Access" />
<input type="button" onClick="removeOptions(withAccess,withoutAccess)"value="Remove Access" />
</FORM>
</BODY>
</HTML>
I've already searched for this problem, but the solutions didn't work for me.
I think the tagname is case sensitive. Use <c:forEach
instead <c:foreach
.
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