title: Java Web application Displaying data from SQL join
body: <p>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.</p>
  
  <p>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:</p>
  
  <pre><code>                              1/1/11                    1/8/11
   CONTRACT   LineCode     Forecast Actual Delta    Forecast Actual Delta 
     B&amp;M       E12-C         12       11    1           25       10    15
     B&amp;M       E11-D         10       15   -5           20       20     0
     Smig      XX2-12        Null     10   -10          20       20     0
     Cartri    WW0-E         etc...
  </code></pre>
  
  <p>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)?  </p>
  
  <p>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)</p>