• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem incrementing loop in jstl

 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to loop and create a table that is 4 columns and "X' amount of rows.

I did a test to loop 40 "lets say products", this should give me 10 rows of 4 columns, but it is giving me 40 rows of 4 columns

i am having trouble incrementing the outer loop as the inner loop loops i need to increment the value of the outer loop also to only loop through the 40 products and end up with 10 rows 4 cols.

Below is my test code

tia
John


[ September 11, 2008: Message edited by: John Schretz ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want the outer loop to iterate 10 times, why are you telling it to iterate 40 times?
 
John Schretz
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am really new to jstl
this is what i ultimatly want to accomplish

i want to get "X" number of products from the DB then create a table that is 4 columns and X amount of rows


[ September 11, 2008: Message edited by: John Schretz ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by John Schretz:
this is what i ultimatly want to accomplish

What is "this"? It's not going to be inferred by looking at code.

If what you are trying to do is to iterate over 40 items in order to put them into a 4 column table, do the math to figure out how many rows you need. Fiddling with the counter is unlikely to get you anywhere, and will just likely have bizarre side effects.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, I caught your ninja edit:

i want to get "X" number of products from the DB then create a table that is 4 columns and X amount of rows


That doesn't seem to match what you said earlier.

But if it is what you are trying to accomplish, what's the issue? Just iterate over the list of products.
 
John Schretz
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i was trying to simulate having 40 products

i was trying to keep incrementing i in the inner loop so whe the loop goes back to the outer loop i has the proper index in the array so to speak

 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You shouldn't be screwing with the counter, and for the life of me I still can't figure out why you are trying to.

The whole point of the tag is that it will handle all that for you -- just give it the collection to iterate over.
 
John Schretz
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok, so i put the collection in the second loop. as per comments in code how do i tell it to only loop 4 times

I think i am having mostly syntax issues here. I am a core java programmer trying to teach myself j2ee ect.

I could figure this out in core java no problem.



thanks
john



[ September 11, 2008: Message edited by: John Schretz ]

[ September 11, 2008: Message edited by: John Schretz ]

[ September 11, 2008: Message edited by: John Schretz ]
[ September 11, 2008: Message edited by: John Schretz ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you even need the inner loop?
 
John Schretz
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
dont i need it to construct the table to go to the next row?




[ September 11, 2008: Message edited by: John Schretz ]
[ September 11, 2008: Message edited by: John Schretz ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic