Example: JSPReportProcessor sample JSP file

Note: Read the Code example disclaimer for important legal information.
<?xml version="1.0"?>
 
<!--
  Copyright (c) 1999 The Apache Software Foundation.  All rights reserved.
-->

<%@ page session="false"%>
<%@ page language="java" contentType="text/html" %>
<%@ page import="java.lang.*" %>
<%@ page import="java.util.*" %>


<%-- <jsp:useBean id='cust_table' scope='page' class='table.JSPcust_table'/> --%>

<%!
   String[][] cust_data = new String [4][5];
   
   public void jspInit()
   {
     //cust_record_field [][] cust_data;
     // cust_record holds customer name, customer address, customer city, customer state,
     // customer zip


     String [] cust_record_1 = {"IBM","3602 4th St","Rochester","Mn","55901"};
     String [] cust_record_2 = {"HP","400 2nd","Springfield","Mo","33559"};	  
     String [] cust_record_3 = {"Wolzack","34 Hwy 52N","Lansing","Or","67895"};	
     String [] cust_record_4 = {"Siems","343 60th","Salem","Tx","12345"};

     cust_data[0] = cust_record_1;
     cust_data[1] = cust_record_2;
     cust_data[2] = cust_record_3;
     cust_data[3] = cust_record_4;
   }
%>

<!-- First test of parse and compose. -->
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
  <fo:layout-master-set>
    <fo:simple-page-master master-name="theMaster" >
    <fo:region-body region-name="theRegion" margin-left=".2in"/>
    </fo:simple-page-master>
    <fo:page-sequence-master master-name="theMaster">
    <fo:single-page-master-reference master-name="thePage"/>
    </fo:page-sequence-master>
  </fo:layout-master-set>
  <fo:page-sequence master-name="theMaster">
   <fo:flow flow-name="theRegion">
     <fo:block>
        <fo:block text-align="center"> NORCAP </fo:block>
        <fo:block space-before=".2in" text-align="center">PAN PACIFIC HOTEL IN SAN FRANCISCO </fo:block>
        <fo:block text-align="center"> FRIDAY, DECEMBER 8-9, 2000 </fo:block>
     </fo:block>
     <fo:block space-before=".5in" font-size="8pt">
     <fo:table table-layout="fixed">
       <fo:table-column column-width="3in"/>
       <fo:table-column column-width="3in"/>
       <fo:table-column column-width="3in"/>
       <fo:table-column column-width="3in"/>
       <fo:table-column column-width="3in"/>
       <fo:table-body>
         <fo:table-row>
            <fo:table-cell column-number="1">
               <fo:block border-bottom-style="solid">NAME</fo:block>
            </fo:table-cell>
            <fo:table-cell column-number="2">
               <fo:block border-bottom-style="solid">ADDRESS</fo:block>
            </fo:table-cell>
            <fo:table-cell column-number="3">
               <fo:block border-bottom-style="solid">CITY</fo:block>
            </fo:table-cell>
            <fo:table-cell column-number="4">
               <fo:block border-bottom-style="solid">STATE</fo:block>
            </fo:table-cell>
            <fo:table-cell column-number="5">
               <fo:block border-bottom-style="solid">ZIP CODE</fo:block>
            </fo:table-cell>
          </fo:table-row>

          <%
            // add row to table
            for(int i = 0; i <= 3; i++)
            {
              String[] _array = cust_data[i];
          %>

          <fo:table-row>
            <fo:table-cell column-number="1">
              <fo:block space-before=".1in">
              <% if(_array[0].equals("IBM")) { %>
                 <fo:inline background-color="blue">
                 <% out.print(_array[0]); %>
                 </fo:inline>
              <% } else { %>
                 <% out.print(_array[0]); %> 
              <% } %>
              </fo:block>
            </fo:table-cell>
            <fo:table-cell column-number="2">
              <fo:block space-before=".1in">
                  <% out.print(_array[1]); %>
              </fo:block>
            </fo:table-cell>
            <fo:table-cell column-number="3">
              <fo:block space-before=".1in">
                  <% out.print(_array[2]); %>
              </fo:block>
            </fo:table-cell> 
            <fo:table-cell column-number="4">
              <fo:block space-before=".1in">
                 <% out.print(_array[3]); %>
              </fo:block>
            </fo:table-cell>  
            <fo:table-cell column-number="5">
             <fo:block space-before=".1in">
                <% out.print(_array[4]); %>
             </fo:block>
           </fo:table-cell>
          </fo:table-row> 

       <%
       } // end row while
       %>

       </fo:table-body>
     </fo:table>
     </fo:block> 
   </fo:flow>
  </fo:page-sequence> 
</fo:root>