File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes How to display in a new  table row after a few records Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to display in a new  table row after a few records" Watch "How to display in a new  table row after a few records" New topic
Author

How to display in a new table row after a few records

Preetha Shenoy
Greenhorn

Joined: Nov 18, 2005
Posts: 10


I have abt 300 records in the resultset. I would like to display say 12 in a row. I tried using another variable j in the for loop but wasnt able to get to make a new <tr>. they still got displayed in a new row.
Kaleb Gary
Greenhorn

Joined: Nov 14, 2005
Posts: 5
Hmmm...

You could use nested for loops.

I've done something similar - and had it work. Simply create use the inner for loop to print out the records to the row. In the outer for loop to add a new row.

[ November 29, 2005: Message edited by: Caleb McGary ]
[ November 29, 2005: Message edited by: Caleb McGary ]
jiju ka
Ranch Hand

Joined: Oct 12, 2004
Posts: 306
Preetha Shenoy
Greenhorn

Joined: Nov 18, 2005
Posts: 10
Thanks a lot Jiju for the solution. Caleb I did the same thing u were suggesting, but that printed each record 12 times. I guess the bigger picture of this solution is to analyze for the 3 different situations firstRow, newRow and last Row. Based on that check whether u r closing and opening the tags appropriately.
Thanks again Jiju.
jiju ka
Ranch Hand

Joined: Oct 12, 2004
Posts: 306
Caleb's solution will also work.
The solution will work if you do the following.

1. i should be incremented by 12. i++ just increments by 1.
2. index of the array should be computed by adding i to j.
3. Precaution should be taken to limit i+j within array size so that Index Out of Bound Exception will not occur.

Similar code...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to display in a new table row after a few records