• Post Reply Bookmark Topic Watch Topic
  • New Topic

for loop JSTL

 
anvi kon
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a scriplet in jsp like below.

}

1. How would I write the above code for loop in JSTL?

I am new to JSTL, I am learning, Can anyone please help me?



for example like below.
I have one employee bean which has got getfirstname(), getlastname();

int size =0;


2. How would I cast with bean to the list using JSTL?





Thanks,





 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Use the c:forEach tag
2. You don't need to cast if you use EL.
 
anvi kon
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for you reply.

Should I use like below.

1.

2.But If I want to use the size value of int size =0

size++;

How would Icast the pagelist using bean with size?

Thanks
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. You're close. The logic is correct, but the syntax is not.
2. You mean that you want to use the index of the loop ? The c:forEach tag has an attribute called "varStatus". You'll be able to get the loop counter there.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Grab a copy of the JSTL specification -- just guessing what the syntax is won't get you far.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!