tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Neil Aggarwal" <n...@JAMMConsulting.com>
Subject Var for c:forEach loop is always null
Date Mon, 11 Dec 2006 22:35:02 GMT
Hello:

According to the c:forEach doc, the var attribute of the
c:forEach tag has nested visibility.

What does that mean?  

I am trying to access the current object of the iteration
and always getting null.

Here is an example:

<%@page language="java" %>
<%@page import="java.util.*" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%
	HashSet<String> mySet = new HashSet<String>();
	mySet.add("Str1");
	mySet.add("Str2");
	mySet.add("Str3");
	mySet.add("Str4");
	mySet.add("Str5");
	mySet.add("Str6");
	mySet.add("Str7");
	
	request.setAttribute("mySet",mySet);
%>	

<c:forEach var="str" items="${mySet}">
  <% String str = (String)request.getAttribute("str"); %>
	<p>
	<%= str %>
</c:forEach>

The value of str is always null.

How can I fix this?

Thanks,
	Neil

--
Neil Aggarwal, (214)986-3533, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Mime
View raw message