• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need Loop to display multiple images  RSS feed

 
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope I am not posting in the wrong forum but the basic algorithm I need is straight Java. I need to display a series of images in a table 5 images across and 3 rows deep. I have that part working with a forEach loop and a counter variable. The problem is, when the number of images is greater than 15, they want to display the next 15 or however many images there are. I was thinking 'continue' but don't think that logic is quite right. This is a web app, and I am printing out <tr> </tr> every time the counter %5 is equal to 0. This gives the desired result for the first 15 images, but I am clueless how to display the remaining images in the same table (in place of the first 15). Hope this is clear enough. I am clueless ???
 
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so, when the user clicks a link "Show Next 15 Images" , the next 15 images replace the ones that are already there? put the image number as a parameter in the link and call the same servlet to get the next 15 images. Same code, different start number.
 
Anne Crace
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply, Tim,

The problem is my jsp is a portlet and I got the first 15 with scriptlet tags (I know, bad practice, but my lead prefers them to jstl and it was easier for me as a pretty green web programmer). I was able to submit the collection and the counter variable to a servlet, but not sure how to go about repopulating the table with the rest of the images. The fact that they exist before any server call confuses me. Maybe I need to check for a variable that doesn't exist yet on page load but will after the servlet is called (return it on the response) ?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!