Murali Mohan wrote:
Hi I am quite new to taglibs. I want to print values in vector or
Iterator.
If I use the following code it is not displaying any thing please help
me.
Thanks,
Murali
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<html>
<body bgcolor="#FFFFFF">
<%!
java.util.Vector v = new java.util.Vector();
%>
<%
v.addElement("Garre");
v.addElement("Rama");
v.addElement("Murali");
v.addElement("Mohan");
%>
<c:forEach var="s" items="${v}">
<c:out value="${s}">
</c:out>
</c:forEach>
</body>
</html>
You need to make the Vector visible to the JSTL EL as well; scripting
variables are only visible to other scripting code, not to actions
such as the <c:forEach> action or the EL. To make it visible, save a
reference in one of the JSP scopes, e.g. like this:
<% pageContext.setAttribute("v", v); %>
to save the reference in the page scope.
Hans
--
Hans Bergsten <[EMAIL PROTECTED]>
Gefion Software <http://www.gefionsoftware.com/>
Author of O'Reilly's "JavaServer Pages", covering JSP 1.2 and JSTL 1.0
Details at <http://TheJSPBook.com/>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant archives, FAQs and Forums on JSPs can be found at:
http://java.sun.com/products/jsp
http://archives.java.sun.com/jsp-interest.html
http://forums.java.sun.com
http://www.jspinsider.com