Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

why c:forEach only display the conten of first row?

 
Kin Charles
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all. I used c:forEach to display an arraylist returned from the javabean. The arraylist contains 8 rows.

While displaying in jsp with

<c:forEach var="pl" items="glist.alist">
<p> <cut values="${pl.id}"/>, <cut values="${pl.name}"/> </p>
</c:forEach>

It display 8 rows but all the content of the first row. What's wrong with ths code?

Thanks for any advice.
[ November 06, 2007: Message edited by: kin charles ]
 
Herman Schelti
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi kin,

did you check what's in your List before it gets used in the .jsp?

Herman
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And also check your second cut tag, as it is not closed.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this with regards to wasting people's time by posting code that's full of errors. Your code, as shown in the post is full of errors and cannot possibly translate and execute as you say.

Please take the time to accurately post the code in question. Otherwise people will quickly learn to ignore your questions.
 
Kin Charles
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Herman and Christophe. With your suggestion, I checked the javabean again and sort out the problem. What I did is changing

Student student1 = new Student();
...
while(rs.next()) {
...
thelist.add(student1);
}

to

...
while(rs.next()) {
Student student1 = new Student();
...
thelist.add(student1);
}

I didn't know the reason but it works now. I am new in javaing.

[ November 07, 2007: Message edited by: Kin Charles ]
[ November 07, 2007: Message edited by: Kin Charles ]
 
Herman Schelti
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Kin,

you added the same student1 over and over to the list, now it's OK

Herman
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!