I have a servlet ( that I cannot change ) to gather information to be displayed in on a web page. I use a bean in a JSP page to loop through the information.
I tried to simplify, but my information is stored tables basically like this
alt text http://img36.imageshack.us/img36/4295/schemase.jpg
So for example, the bean stores information in nested arrays like this:
---2009
------TOYOTA
---------BLUE 10
---------RED 20
------CHEVY
---------BLUE 30
---------RED 10
---2010
------TOYOTA
---------BLUE 30
---------RED 12
------CHEVY
---------BLUE 12
---------RED 20
This is great for when I display the report per year, per category, per color. I can easily loop through the years, loop through the categories, then loop through the colors. This is the report I have ( simplified )
alt text http://img841.imageshack.us/img841/3666/reportihave.jpg
Now I need to turn that information sideways. I need to create a report to display the count per color, per year. This is the report I need:
alt text http://img33.imageshack.us/img33/461/reportineed.jpg
How can I rearrange the information within the JSP? Should I use arrays to gather the info, or is there an equivalent to a hash that I can use?
Thanks
I solved the problem by looping though the lists in the bean until I got to the color list, then started looping through again and again until I found all the records for each color.
Is it efficient? No.
Is it a good use of JSTL? No.
But I am stuck. I cannot change anything in the bean, I had to use JSP to do the work.