Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JSP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
JSP
printing index of an collection in JSP using JSTL
James Workmen
Greenhorn
Posts: 26
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I want to print the index of an collection, as weel as the data
right now I am doing
<c:forEach var="codebean" items="${PROJECT_LIST}" > <c :-o ut value="${codebean.name}"/> <input type="hidden" name="rank" value="$[B]{index}"/[/B]> <--Print the index here </c:forEach>
I know I can do this,
<c:forEach var="index" begin="${0}" end="${fn:length(PROJECT_LIST)-1}" >
but I cannot combine both,
<c:forEach var="codebean" items="${PROJECT_LIST}" var="index" begin="${0}" end="${fn:length(PROJECT_LIST)-1}" > <c :-o ut value="${codebean.name}"/> <input type="hidden" name="rank" value="${index}"/> <--Print the index here </c:forEach>
Help!!
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
<c:forEach var="codebean" items="${projectList}" varStatus="loopStatus"> <c:out value="${codebean.name}"/> <input type="hidden" name="rank" value="${loopStatus.index}"/> </c:forEach>
Notes:
1) I changed PROJECT_LIST to projectList according to accepted naming conventions.
2) varStatus creates a scoped variable of type LoopTagStatus which exports a number of useful properties, including the loop index.
3) I clicked 'disable smilies' when posting so that my <c:out> tags don't look so surprised.
[ December 02, 2004: Message edited by: Bear Bibeault ]
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
James Workmen
Greenhorn
Posts: 26
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thank you, I appreciate your help and tips on posting.
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Null value in ActionForm after javascript submit()
mock 5 - 78% score - experiences
IE bug ? field too long ?
How to do database pagination using JSTL tags
JSP 2.0 EL and html:options issue
More...