jsp-tags


JSP foreach tag for two variables


I want to do something like this
<c:forEach var="item1" items="List1" var="item2" items="List2">
<p> ${item1} ${item2}</p>
</c:forEach>
One solution is to iterate through both the List, if both are of same size
<c:forEach var="i" begin="0" end="$(fn:length(List1))">
<p> <%= List1.get(i) %> <%= List2.get(i)%> //wrong syntax
</c:forEach>
Any idea how to achieve this.
You can call varStatus.index to get the index of the current round and then use it as a lookup for the second list. Mind the length of the Lists though or it will throw an Exception . Set the items with the List having maximum of the two.
<c:forEach var="element" items="${List1}" varStatus="status">
<p>
${element}
${List2[status.index]}
</c:forEach>
Documentation.
How to avoid Java Code in JSP-Files?
Array is Frist List, and B is Second List and varStatus.index to get the index of the current round and then use it as a lookup for the second list.
<c:forEach var="Array" items="${A}" varStatus="status">
<c:out value="${A}","${B[status.index]}"}/>
</c:forEach>

Related Links

JSP foreach tag for two variables
Adding Parameter to href tag before uri
Servlet exception stream closed jsp
creating and exporting a csv from Display tag table
bean write to number type id
restrict image file size in alloy UI
The function getContextPath must be used with a prefix when a default namespace is not specified
how can i retrive parameters from EncodeURL using jsp?
onclick tag giving error in h:commandLink
Displaytag - How to pass hidden value in url?
Embedding Tag Files in a JAR
Errors when the compiler is trying to build a custom JSP tag based on an Java Bean
Creating nested custom tag using jsp2 tag files
Unable to access session on JSP
Dealing with <html:options>
No tag “tableFacade” defined in tag library imported with prefix “jmesa”

Categories

HOME
log4j
c#-4.0
relative-path
at-command
programming-languages
filtering
elm
rdf
ios-charts
vault
try-catch
apache-metamodel
undefined
oracle-coherence
sms-gateway
code-review
nhibernate-envers
introduction
grails3
opencover
errorlevel
telerik-reporting
microsoft-r
one-to-many
pepper
facet
frame
galsim
exuberant-ctags
typed.js
mozilla
y86
hexo
overlap
io-redirection
serverside-rendering
unobtrusive-validation
ibpy
flashair
scorm
long-polling
osx-mavericks
dandelion
powercli
diagnostics
yt-project
root-framework
grails-tomcat-plugin
prettytensor
suffix-tree
design-by-contract
energy
execute
lemon
eclipse-clp
jmeter-maven-plugin
quicklisp
rgeo
emailrelay
android-listview
event-bubbling
clipperlib
notify
dia
website-monitoring
dd
file-copying
flask-cors
article
undefined-reference
intentservice
imdbpy
jsctypes
tidy
ftps
back-stack
interface-orientation
ember-app-kit
dice
errai
objective-c-2.0
postgresql-performance
hgsubversion
php-parser
nsobject
pydot
propagation
android-sdk-2.1
infrastructure
virtual-functions
boost-smart-ptr
thread-local-storage
caching-application-block

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App