Murali Mohan wrote:
Thanks to your reply. It is working.
But If I have 10 vectors to display data , Should I put 10 in session(or some
scope) before displaying data??????
Which scope you select depends on the data, for instance if it rarely
changes and is the same for all users, the application scope may be
the best, if it's different per user but stays the same throughout the
session, use the session scope, etc.
Can't I use set tag to make it visible?????????????
like.............
<c:set var="Garre" scope="page" value="${v}" />
<c:forEach var="s" items="${Garre}">
<c:out value="${s}">
</c:out>
</c:forEach>
If you use servlets for the business logic and JSP pages only for
the user interface, the servlets typically put items like this in
the appropriate scope. If you only use JSP pages, a custom action
("tag") that creates the data could also save it directly in a scope.
For the simple example you provided, where the data is created as a
Vector in a scriptlet, you must also use a scriptlet to save the
reference; there's no way any action (standard or custom) can get
hold of the value of a scripting variable and do anything with it.
For instance, above you have just moved the problem to the <c:set>
action instead of the <c:forEach> action: ${v} can only be resolved
if "v" is a variable (reference) in one of the JSP scopes.
I describe this in much more detail in my book. See the signature at
the end for more info.
Hans
Hans Bergsten wrote:
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
===========================================================================
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
--
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