Hello,

At present i am creating a web page to make a report using Java. (Data queried
from Oracle database).

i have created the report and everything is Ok, except that the HTML table
in which the header and the data is populated is created at the bottom of
the Web page, if i print the Web page to the printer, the table will be printed
on the 8th - 9th page. On the Screen i have to scrol at the bottom of the
page to see it.
i am using Rowspan and Colspan for formating the Header.
If i don't use Rowspan and Colspan for formating the Header and create a
simple header i don't have this problem.
(But formating of the header is needed for the report)
i am new to this so can anyone please advise me where i am going wrong or
is there any better way of formating the header to get similar output using
some other code in Java rather than using Rowspan and Colspan.

i am putting relevant part of my Java code here.

Look for
****** Drawing of Header
****** Populating the Details
where you will fing the codes for drawing the table.

Please let me know about it.

out.println("<body bgcolor=\"#CCCCCC\" text=\"#000000\" >");

out.println(" <table width=\"700\" border=\"0\" cellpadding=\"0\"
cellspacing=\"0\">");
out.println(" <tr> ");
out.println(" <td width=\"112\" valign=\"top\" rowspan=\"2\"><img
src=\"../logo/oub_manulife.gif\"></td>");
out.println(" <td width=\"30\" height=\"46\"></td>");
out.println(" <td width=\"347\"></td>");
out.println(" <td width=\"211\"></td>");
out.println(" </tr>");
out.println("</table>");

out.println(" <table width=\"700\" border=\"0\" cellpadding=\"0\"
cellspacing=\"0\">");
out.println(" <tr> ");
out.println(" <td height=\"25\"></td>");
out.println(" <td valign=\"top\"><font color=\"#0000FF\" size=\"5\"><b>MIS
Report</b></font></td>");
// out.println(" <td><div align=\"right\"><b>Date: " + todaysDate
+ "</b></div></td>");
out.println(" <td><div align=\"right\"><b>Date: " + sTDate + "</b></div></td>");
out.println(" </tr>");
out.println("</table>");


out.println(" <table width=\"700\" border=\"0\" cellpadding=\"0\"
cellspacing=\"0\">");
out.println(" <tr> ");
out.println(" <td height=\"21\"><hr></td>");
out.println(" </tr>");
out.println("</table>");

// <<<<< ****** Drawing of Header Starts here
out.println("<table width=\"100%\" border=\"1\">");
out.println("* <tr>");
out.println("*** <td width=\"12%\" rowspan=\"4\" bgcolor=\"#FFFF99\">
<div align=\"center\"><font size=\"2\"><b>Branch</b></font></div></td>");
out.println("*** <td colspan=\"4\" bgcolor=\"#999999\"><div align=\"center\"><font
size=\"2\"><b>Case</b></font></div></td>");
out.println("*** <td colspan=\"4\" bgcolor=\"#99CCCC\"><div align=\"center\"><font
size=\"2\"><b>NAC</b></font></div></td>");
out.println("*** <td colspan=\"5\" bgcolor=\"#99CC99\"><div align=\"center\"><font
size=\"2\"><b>Manpower</b></font></div></td>");
out.println("* </tr>");
out.println("* <tr>");
out.println("*** <td bgcolor=\"#999999\"> <div align=\"center\"><font
size=\"2\"><b>2002</b></font></div></td>");
out.println("*** <td colspan=\"3\" bgcolor=\"#999999\"><div align=\"center\"><font
size=\"2\"><b>2003</b></font></div></td>");
out.println("*** <td bgcolor=\"#99CCCC\"> <div align=\"center\"><font
size=\"2\"><b>2002</b></font></div></td>");
out.println("*** <td colspan=\"3\" bgcolor=\"#99CCCC\"><div align=\"center\"><font
size=\"2\"><b>2003</b></font></div></td>");
out.println("*** <td colspan=\"5\" bgcolor=\"#99CC99\"> <div align=\"center\"><font
size=\"2\"><b>2003</b></font></div></td>");
out.println("* </tr>");
out.println("* <tr>");
out.println("*** <td width=\"40\" rowspan=\"2\" bgcolor=\"#999999\">
<div align=\"center\"><font size=\"1\"><b>Actual @ Mth End</b></font></div></td>");
out.println("*** <td width=\"40\" rowspan=\"2\" bgcolor=\"#999999\">
<div align=\"center\"><font size=\"1\"><b>Actual</b></font></div></td>");
out.println("*** <td width=\"40\" rowspan=\"2\" bgcolor=\"#999999\">
<div align=\"center\"><font size=\"1\"><b>Goal @ Mth End </b></font></div></td>");
out.println("*** <td width=\"40\" rowspan=\"2\" bgcolor=\"#999999\">
<div align=\"center\"><font size=\"1\"><b>% to goal</b></font></div></td>");
out.println("*** <td width=\"40\" rowspan=\"2\" bgcolor=\"#99CCCC\">
<div align=\"center\"><font size=\"1\"><b>Actual @ Mth End</b></font></div></td>");
out.println("*** <td width=\"40\" rowspan=\"2\" bgcolor=\"#99CCCC\">
<div align=\"center\"><font size=\"1\"><b>Actual</b></font></div></td>");
out.println("*** <td width=\"40\" rowspan=\"2\" bgcolor=\"#99CCCC\">
<div align=\"center\"><font size=\"1\"><b>Goal @ Mth End </b></font></div></td>");
out.println("*** <td width=\"40\" rowspan=\"2\" bgcolor=\"#99CCCC\">
<div align=\"center\"><font size=\"1\"><b>% to goal</b></font></div></td>");
out.println("*** <td width=\"40\" rowspan=\"2\" bgcolor=\"#99CC99\">
<div align=\"center\"><font size=\"1\"><b>Recruited @ Last Mth End</b></font></div></td>");
out.println("*** <td width=\"40\" rowspan=\"2\" bgcolor=\"#99CC99\">
<div align=\"center\"><font size=\"1\"><b>Terminated*@ Last Mth End</b></font></div></td>");
out.println("*** <td colspan=\"3\" bgcolor=\"#99CC99\"> <div align=\"center\"><font
size=\"1\"><b>Net @ Last Mth End</b></font></div><font size=\"1\">&nbsp;</font><font
size=\"1\">&nbsp;</font></td>");
out.println("* </tr>");
out.println("* <tr>");
out.println("*** <td width=\"40\" bgcolor=\"#99CC99\"> <div align=\"center\"><font
size=\"1\"><b>Actual</b></font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#99CC99\"> <div align=\"center\"><font
size=\"1\"><b>Goal</b></font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#99CC99\"> <div align=\"center\"><font
size=\"1\"><b>% to goal</b></font></div></td>");
out.println("* </tr>");

// >>>>> ****** Drawing of Header ends here

try {
statement = connection.createStatement();
} catch(SQLException e) {
System.out.println("** Error ** Cannot Create Statement in List
New Biz Case, abort");
out.println("<h1>** Attempt to connect...**</h1>");
NBConnectDB();
out.println("** Attempt to connect succeed **");
}

try {

qryStr = buildSQL.listAllCases(sCond,sTDate);
ResultSet rs = statement.executeQuery(qryStr);
while(rs.next()) {
count++;
strbr_nm = rs.getString("br_nm");
vTDNAC = ( double ) rs.getDouble("TDNAC");
vLYNAC = ( double ) rs.getDouble("LYNAC");
vTDCNT = ( double ) rs.getDouble("TDCNT");
vLYCNT = ( double ) rs.getDouble("LYCNT");
vOBNAC = ( double ) rs.getDouble("OBNAC");
vOBCNT = ( double ) rs.getDouble("OBCNT");
vOBMAN = ( double ) rs.getDouble("OBMAN");
vTDMAN = ( double ) rs.getDouble("TDMAN");
vTDTER = ( double ) rs.getDouble("TDTER");
vTDREC = ( double ) rs.getDouble("TDREC");

{ svTDNAC = twoDecimals.format(vTDNAC); }
{ svLYNAC = twoDecimals.format(vLYNAC); }
{ svTDCNT = twoDecimals.format(vTDCNT); }
{ svLYCNT = twoDecimals.format(vLYCNT); }
{ svOBNAC = twoDecimals.format(vOBNAC); }
{ svOBCNT = twoDecimals.format(vOBCNT); }
{ svOBMAN = twoDecimals.format(vOBMAN); }
{ svTDMAN = twoDecimals.format(vTDMAN); }
{ svTDTER = twoDecimals.format(vTDTER); }
{ svTDREC = twoDecimals.format(vTDREC); }

tTDNAC = tTDNAC + vTDNAC;
tLYNAC = tLYNAC + vLYNAC;
tTDCNT = tTDCNT + vTDCNT;
tLYCNT = tLYCNT + vLYCNT;
tOBNAC = tOBNAC + vOBNAC;
tOBCNT = tOBCNT + vOBCNT;
tOBMAN = tOBMAN + vOBMAN;
tTDMAN = tTDMAN + vTDMAN;
tTDTER = tTDTER + vTDTER;
tTDREC = tTDREC + vTDREC;

{ stTDNAC = twoDecimals.format(tTDNAC); }
{ stLYNAC = twoDecimals.format(tLYNAC); }
{ stTDCNT = twoDecimals.format(tTDCNT); }
{ stLYCNT = twoDecimals.format(tLYCNT); }
{ stOBNAC = twoDecimals.format(tOBNAC); }
{ stOBCNT = twoDecimals.format(tOBCNT); }
{ stOBMAN = twoDecimals.format(tOBMAN); }
{ stTDMAN = twoDecimals.format(tTDMAN); }
{ stTDTER = twoDecimals.format(tTDTER); }
{ stTDREC = twoDecimals.format(tTDREC); }

{
if (vTDCNT ==0)
vCol5 = 0;
if (vOBCNT ==0)
vCol5 = 0;
else
vCol5 = vTDCNT / vOBCNT * 100;
}
{
if (vTDNAC ==0)
vCol9 = 0;
if (vOBNAC ==0)
vCol9 = 0;
else
vCol9 = vTDNAC / vOBNAC * 100;
}
{
if (vTDMAN ==0)
vCol14 = 0;
if (vOBMAN ==0)
vCol14 = 0;
else
vCol14 = vTDMAN / vOBMAN * 100;
}

{ svCol5 = twoDecimals.format(vCol5); }
{ svCol9 = twoDecimals.format(vCol9); }
{ svCol14 = twoDecimals.format(vCol14); }

tCol5 = tTDCNT / tOBCNT * 100;
tCol9 = tTDNAC / tOBNAC * 100;
tCol14 = tTDMAN / tOBMAN * 100;
{ stCol5 = twoDecimals.format(tCol5); }
{ stCol9 = twoDecimals.format(tCol9); }
{ stCol14 = twoDecimals.format(tCol14); }

// System.out.println("vTDNAC : " + vTDNAC);

out.println("<form name=\"MisRepGet\" method=\"post\" action=\"\">");
// <<<<< ****** Populating the Details Starts here
out.println("* <tr>");
out.println("*** <td bgcolor=\"#FFFF99\"><div align=\"left\"><font
size=\"1\">" + strbr_nm + "</font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#999999\"> <div
align=\"right\"><font size=\"1\">" + svLYCNT + "</font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#999999\"> <div
align=\"right\"><font size=\"1\">" + svTDCNT + "</font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#999999\"> <div
align=\"right\"><font size=\"1\">" + svOBCNT + "</font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#999999\"> <div
align=\"right\"><font size=\"1\">" + svCol5 + "</font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#99CCCC\"> <div
align=\"right\"><font size=\"1\">" + svLYNAC + "</font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#99CCCC\"> <div
align=\"right\"><font size=\"1\">" + svTDNAC + "</font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#99CCCC\"> <div
align=\"right\"><font size=\"1\">" + svOBNAC + " </font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#99CCCC\"> <div
align=\"right\"><font size=\"1\">" + svCol9 + "</font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#99CC99\"> <div
align=\"right\"><font size=\"1\">" + svTDREC + "</font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#99CC99\"> <div
align=\"right\"><font size=\"1\">" + svTDTER + "</font></div> </td>");
out.println("*** <td width=\"40\" bgcolor=\"#99CC99\"> <div
align=\"right\"><font size=\"1\">" + svTDMAN + "</font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#99CC99\"> <div
align=\"right\"><font size=\"1\">" + svOBMAN + "</font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#99CC99\"> <div
align=\"right\"><font size=\"1\">" + svCol14 + "</font></div></td>");
out.println("* </tr>");
}

} catch ( SQLException e ) {
System.out.println("Select Query error " + e );
};
out.println("* <tr>");
out.println("*** <td bgcolor=\"#FFFF99\"><div align=\"right\"><font
size=\"1\"><b>Total</b></font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#999999\"> <div align=\"right\"><font
size=\"1\"><b>" + stLYCNT + "</b></font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#999999\"> <div align=\"right\"><font
size=\"1\"><b>" + stTDCNT + "</b></font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#999999\"> <div align=\"right\"><font
size=\"1\"><b>" + stOBCNT + "</b></font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#999999\"> <div align=\"right\"><font
size=\"1\"><b>" + stCol5 + "</b></font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#99CCCC\"> <div align=\"right\"><font
size=\"1\"><b>" + stLYNAC + "</b></font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#99CCCC\"> <div align=\"right\"><font
size=\"1\"><b>" + stTDNAC + "</b></font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#99CCCC\"> <div align=\"right\"><font
size=\"1\"><b>" + stOBNAC + "</b></font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#99CCCC\"> <div align=\"right\"><font
size=\"1\"><b>" + stCol9 + "</b></font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#99CC99\"> <div align=\"right\"><font
size=\"1\"><b>" + stTDREC + "</b></font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#99CC99\"> <div align=\"right\"><font
size=\"1\"><b>" + stTDTER + "</b></font></div> </td>");
out.println("*** <td width=\"40\" bgcolor=\"#99CC99\"> <div align=\"right\"><font
size=\"1\"><b>" + stTDMAN + "</b></font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#99CC99\"> <div align=\"right\"><font
size=\"1\"><b>" + stOBMAN + "</b></font></div></td>");
out.println("*** <td width=\"40\" bgcolor=\"#99CC99\"> <div align=\"right\"><font
size=\"1\"><b>" + stCol14 + "</b></font></div></td>");
out.println("* </tr>");
// >>>>> ****** Populating the Details Ends here
out.println("</form>");
out.println("</body>");
out.println("</table>");
out.close();
}