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

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”
how to refer values of one jsp file to other jsp
incorrect username and passwords
creating the welcome page
How to use list object in <c:forEach tag?

Categories

HOME
wso2-am
wso2
angular-material
stock
session
objectgears
mean-stack
yarn
graphql
wamp
azure-storage-tables
ios-charts
paradox
contact
awesome-wm
primary-key
facebook-php-sdk
spring-kafka
modelica
collectd
gz
ibm-odm
clojurescript
facebook-page
evopdf
nhibernate-envers
swingx
intentfilter
telerik-reporting
tibco-mdm
devops
restful-authentication
buildbot
rst2pdf
fopen
maquette
neo4j-spatial
c++-amp
procdump
google-cloud-endpoints-v2
perlin-noise
windows-dev-center
hexo
fusionpbx
jquery-bootgrid
total-commander
user-accounts
taffy
ionicons
winscp-net
feeds
nsarray
nbconvert
angular-strap
word-vba-mac
setuptools
removechild
azure-virtual-network
tform
phpcas
hsv
unity-networking
intellij-14
arcanist
unity5.2.3
java.util.concurrent
java.nio.file
ccss
quartz-graphics
flashvars
selected
pvrtc
appconkit
blackberry-playbook
psi
servicehost
recent-documents
inotifycollectionchanged
cxxtest
blitz++
.nettiers
thread-local-storage
data-acquisition

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