I have two db tables. One table contains Forecast data. The second table contains Actual data. I have two javabeans that represent each of these tables.
I want a jsp view (JSTL/EL) that lists the forcasted data, the actual data and then delta between the two in groups of weekly dates, such as this:
1/1/11 1/8/11
CONTRACT LineCode Forecast Actual Delta Forecast Actual Delta
B&M E12-C 12 11 1 25 10 15
B&M E11-D 10 15 -开发者_StackOverflow中文版5 20 20 0
Smig XX2-12 Null 10 -10 20 20 0
Cartri WW0-E etc...
Should I create a 3rd javabean that represents the view above from a SQL JOIN and do all the math in servlets (Or possibly in the SQL itself)?
Or do I pass the two beans and do the math in the jsp view? If I do the latter, I'm not sure how to do the looping efficiently with jstl. The two db tables may not have the exact same order or number of rows (as seen with the Null value in the SMIG contract above)
In order of preference:
1) Do it in the database,
2) Do it in a POD (JavaBean)
3) (A distant third) Do it in the JSP.
精彩评论