hi, my problem is that i have a database where i have stored information month wise of various user and i want that user details in month wise and its shows too but when its move to another column like means in next month like jan to feb its creats a equal rows in each time when ever its move to next column.

so i want that rows sud not create after such number so please help me out if you hav solution because it really making me tired of working with it.

Dani AI

Generated

Diagnosis and a compact fix plan (no scriptlets, single set of component rows)

The symptom is that the page prints the full block of component rows for every database record read. As noted, the correct pattern is to move DB work out of the JSP and assemble a data structure that represents months -> component values, then render the table once (one table row per component, 12 columns for months). The simplest, reliable approach is:

  1. In a servlet/bean, run a query that returns month + component columns (use an alias for the month column).
  2. Build a month-keyed Map of component→value (use a TreeMap to keep months sorted).
  3. Put that Map and an ordered list of component labels into the request and forward to a JSP that uses JSTL/EL to render the table.

Example (servlet/bean data assembly):

String[] components = { "Basic", "Allowance", "Bonus", "Arrear", "Fringe", "PF_Employer", "PF_Employee", "TDS", "Other", "Subtotal", "Net" };
Map<Integer,Map<String,String>> byMonth = new TreeMap<>();

String sql = "SELECT MONTH(date_of_receipt) AS m, basic_sal, allowance, bonus, arrear, value_of_fringe, con_toprov, ded_cont_prov_emplee, tds, other, sub_total, netamnt FROM salary_employ WHERE emp_id = ?";
PreparedStatement ps = conn.prepareStatement(sql);
ps.setInt(1, empId);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
  int m = rs.getInt("m");
  Map<String,String> map = byMonth.get(m);
  if (map == null) { map = new HashMap<>(); byMonth.put(m, map); }
  map.put("Basic", rs.getString("basic_sal"));
  map.put("Allowance", rs.getString("allowance"));
  // ... fill remaining component keys
}
request.setAttribute("salaryByMonth", byMonth);
request.setAttribute("components", Arrays.asList(components));

Example (JSP rendering with JSTL):

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<table>
  <tr><th>Component</th><c:forEach begin="1" end="12" var="m"><th>${m}</th></c:forEach></tr>
  <c:forEach var="comp" items="${components}">
    <tr>
      <td>${comp}</td>
      <c:forEach begin="1" end="12" var="mi">
        <td><c:out value="${salaryByMonth[mi][comp]}" default=""/></td>
      </c:forEach>
    </tr>
  </c:forEach>
</table>

Notes and troubleshooting

  • Use a DataSource/JNDI connection pool rather than creating connections in JSP.
  • Use BigDecimal for money and format on the view.
  • If the financial year does not start in January, build a month order list that begins with the fiscal start month.
  • If some months are missing, the Map lookup will be null; the JSP code above prints an empty cell.
  • Log the Map size while debugging to confirm 12 (or expected) keys before rendering.

This follows 's advice (no heavy scriptlets) while giving a concrete, maintainable way to pivot DB rows into columns for monthwise display.

Recommended Answers

All 4 Replies

We would if we had any idea what you were talking about.

Provide the relevant table information, and the code you're using to access it, and a better description of exactly what you expect as compared to what you get.

Dear Sir
I m making a project which will display the salary report of a financial year monthwise,which is input by the user every month.I have made a table which will display it but it is increasing the row when the next row in the database is read.

my code is

<HTML><HEAD><TITLE>New Document</TITLE>
<BODY>
<input type="hidden" name="sr_no">
 <%@ page import="java.util.*" %>


 <%@ page import="java.text.*"%>

 <%@ page import="java.io.*"%> 
<%@ page import="javax.sql.*"%> 
<%@ page import="java.io.*"%>
<%@ page import="java.sql.*"%>

<%
String url="jdbc:mysql://localhost/3306/accounting";
        //String url="jdbc:odbc:jvaccess";
String host = "localhost"; // default value
String port = "3306";      // default value
String user = "root";          // command line arg 0
String password = "";      // command line arg 1
String database = "accounting";      // command line arg 2
Connection con=null;

PreparedStatement pt;

Statement st;

try
    {
Class.forName("com.mysql.jdbc.Driver").newInstance();
 con = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database + 
            "?user=" + user + "&password=" + password);
}
 catch(java.lang.ClassNotFoundException e1) 
        {   
             System.err.print("Class Not Found Exception: "); 
             System.err.println(e1.getMessage());
        }
st = con.createStatement();
String st1="select month(date_of_receipt),name_of_emp,date_of_join,designation,salary_pack,sal_for_mon,basic_sal,allowance,bonus,arrear,value_of_fringe,con_toprov,other,sub_total,ded_cont_prov_employer,ded_cont_prov_emplee,tds,anyothrded,subtot,netamnt,date_of_receipt from salary_employ";
ResultSet rs=st.executeQuery(st1);
%><table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="1006" height="509">
  <tr>
    <td width="127" height="19">&nbsp;</td>
    <td width="61" height="19">January</td>
    <td width="66" height="19">February</td>
    <td width="60" height="19">March</td>
    <td width="66" height="19">April</td>
    <td width="67" height="19">May</td>
    <td width="64" height="19">June</td>
    <td width="64" height="19">July</td>
    <td width="79" height="19">August</td>
    <td width="79" height="19">September</td>
    <td width="79" height="19">October</td>
    <td width="103" height="19">November</td>
    <td width="77" height="19">December</td>
  </tr><%
while(rs.next())
{

String nameofemp=rs.getString("name_of_emp");
String dateofjoin=rs.getString("date_of_join");
String designation=rs.getString("designation");
String salary_pack=rs.getString("salary_pack");
String sal_for_mon=rs.getString("sal_for_mon");
String basic_sal=rs.getString("basic_sal");
String allowance=rs.getString("allowance");
String bonus=rs.getString("bonus");
String arrear=rs.getString("arrear");
String value_of_fringe=rs.getString("value_of_fringe");
String con_toprov=rs.getString("con_toprov");
String other=rs.getString("other");
String sub_total=rs.getString("sub_total");
String ded_cont_prov_employer=rs.getString("ded_cont_prov_employer");
String ded_cont_prov_emplee=rs.getString("ded_cont_prov_emplee");
String tds=rs.getString("tds");
String anyothrded=rs.getString("anyothrded");
String subtot=rs.getString("subtot");
String netamnt=rs.getString("netamnt");
Integer date_of_receipt=rs.getInt("month(date_of_receipt)");

%>
  <tr>

    <td width="127" height="19">Basic Salary</td>
    <td width="61" height="19"> <%if(date_of_receipt==1)
    {
    out.println(basic_sal);%><%}%></td>
    <td width="66" height="19"><%if(date_of_receipt==2)
    {
    out.println(basic_sal);%><%}%></td>
    <td width="60" height="19"><%if(date_of_receipt==3)
    {
    out.println(basic_sal);%><%}%></td>
    <td width="66" height="19"><%if(date_of_receipt==4)
    {
    out.println(basic_sal);%><%}%></td>
    <td width="67" height="19"><%if(date_of_receipt==5)
    {
    out.println(basic_sal);%><%}%></td>
    <td width="64" height="19"><%if(date_of_receipt==6)
    {
    out.println(basic_sal);%><%}%></td>
    <td width="64" height="19"><%if(date_of_receipt==7)
    {
    out.println(basic_sal);%><%}%></td>
    <td width="79" height="19"><%if(date_of_receipt==8)
    {
    out.println(basic_sal);%><%}%></td>
    <td width="79" height="19"><%if(date_of_receipt==8)
    {
    out.println(basic_sal);%><%}%></td>
    <td width="79" height="19"><%if(date_of_receipt==10)
    {
    out.println(basic_sal);%><%}%></td>
    <td width="103" height="19"><%if(date_of_receipt==11)
    {
    out.println(basic_sal);%><%}%></td>
    <td width="77" height="19"><%if(date_of_receipt==12)
    {
    out.println(basic_sal);%><%}%></td>
  </tr>
  <tr>
    <td width="127" height="19">Allowance</td>
    <td width="61" height="19"><%if(date_of_receipt==1)
    {
    out.println(allowance);%><%}%></td>
    <td width="66" height="19"><%if(date_of_receipt==2)
    {
    out.println(allowance);%><%}%></td>
    <td width="60" height="19"><%if(date_of_receipt==3)
    {
    out.println(allowance);%><%}%></td>
    <td width="66" height="19"><%if(date_of_receipt==4)
    {
    out.println(allowance);%><%}%>&nbsp;</td>
    <td width="67" height="19"><%if(date_of_receipt==5)
    {
    out.println(allowance);%><%}%></td>
    <td width="64" height="19"><%if(date_of_receipt==6)
    {
    out.println(allowance);%><%}%></td>
    <td width="64" height="19"><%if(date_of_receipt==7)
    {
    out.println(allowance);%><%}%></td>
    <td width="79" height="19"><%if(date_of_receipt==8)
    {
    out.println(allowance);%><%}%></td>
    <td width="79" height="19"><%if(date_of_receipt==9)
    {
    out.println(allowance);%><%}%></td>
    <td width="79" height="19"><%if(date_of_receipt==10)
    {
    out.println(allowance);%><%}%></td>
    <td width="103" height="19"><%if(date_of_receipt==11)
    {
    out.println(allowance);%><%}%></td>
    <td width="77" height="19"><%if(date_of_receipt==12)
    {
    out.println(allowance);%><%}%></td>
    <tr>
    <td width="127" height="40">Bonus</td>
    <td width="61" height="40"><%if(date_of_receipt==1)
    {
    out.println(bonus);%><%}%></td>
    <td width="66" height="40"><%if(date_of_receipt==2)
    {
    out.println(bonus);%><%}%></td>
    <td width="60" height="40"><%if(date_of_receipt==3)
    {
    out.println(bonus);%><%}%></td>
    <td width="66" height="40"><%if(date_of_receipt==4)
    {
    out.println(bonus);%><%}%></td>
    <td width="67" height="40"><%if(date_of_receipt==5)
    {
    out.println(bonus);%><%}%></td>
    <td width="64" height="40"><%if(date_of_receipt==6)
    {
    out.println(bonus);%><%}%></td>
    <td width="64" height="40"><%if(date_of_receipt==7)
    {
    out.println(bonus);%><%}%></td>
    <td width="79" height="40"><%if(date_of_receipt==8)
    {
    out.println(bonus);%><%}%></td>
    <td width="79" height="40"><%if(date_of_receipt==9)
    {
    out.println(bonus);%><%}%></td>
    <td width="79" height="40"><%if(date_of_receipt==10)
    {
    out.println(bonus);%><%}%></td>
    <td width="103" height="40"><%if(date_of_receipt==11)
    {
    out.println(bonus);%><%}%></td>
    <td width="77" height="40"><%if(date_of_receipt==12)
    {
    out.println(bonus);%><%}%></td>

  </tr>
  <tr>
    <td width="127" height="35">Arrear Of Salary</td>
    <td width="61" height="35"><%if(date_of_receipt==1)
    {
    out.println(arrear);%><%}%></td>
    <td width="66" height="35"><%if(date_of_receipt==2)
    {
    out.println(arrear);%><%}%></td>
    <td width="60" height="35"><%if(date_of_receipt==3)
    {
    out.println(arrear);%><%}%></td>
    <td width="66" height="35"><%if(date_of_receipt==4)
    {
    out.println(arrear);%><%}%></td>
    <td width="67" height="35"><%if(date_of_receipt==5)
    {
    out.println(arrear);%><%}%></td>
    <td width="64" height="35"><%if(date_of_receipt==6)
    {
    out.println(arrear);%><%}%></td>
    <td width="64" height="35"><%if(date_of_receipt==7)
    {
    out.println(arrear);%><%}%></td>
    <td width="79" height="35"><%if(date_of_receipt==8)
    {
    out.println(arrear);%><%}%></td>
    <td width="79" height="35"><%if(date_of_receipt==9)
    {
    out.println(arrear);%><%}%></td>
    <td width="79" height="35"><%if(date_of_receipt==10)
    {
    out.println(arrear);%><%}%></td>
    <td width="103" height="35"><%if(date_of_receipt==11)
    {
    out.println(arrear);%><%}%></td>
    <td width="77" height="35"><%if(date_of_receipt==12)
    {
    out.println(arrear);%><%}%></td>
  </tr>
  <tr>
    <td width="127" height="45">Value Of Fringe Benefits</td>
    <td width="61" height="45"><%if(date_of_receipt==1)
    {
    out.println(value_of_fringe);%><%}%></td>
    <td width="66" height="45"><%if(date_of_receipt==2)
    {
    out.println(value_of_fringe);%><%}%></td>
    <td width="60" height="45"><%if(date_of_receipt==3)
    {
    out.println(value_of_fringe);%><%}%></td>
    <td width="66" height="45"><%if(date_of_receipt==4)
    {
    out.println(value_of_fringe);%><%}%></td>
    <td width="67" height="45"><%if(date_of_receipt==5)
    {
    out.println(value_of_fringe);%><%}%></td>
    <td width="64" height="45"><%if(date_of_receipt==6)
    {
    out.println(value_of_fringe);%><%}%></td>
    <td width="64" height="45"><%if(date_of_receipt==7)
    {
    out.println(value_of_fringe);%><%}%></td>
    <td width="79" height="45"><%if(date_of_receipt==8)
    {
    out.println(value_of_fringe);%><%}%></td>
    <td width="79" height="45"><%if(date_of_receipt==9)
    {
    out.println(value_of_fringe);%><%}%></td>
    <td width="79" height="45"><%if(date_of_receipt==10)
    {
    out.println(value_of_fringe);%><%}%></td>
    <td width="103" height="45"><%if(date_of_receipt==11)
    {
    out.println(value_of_fringe);%><%}%></td>
    <td width="77" height="45"><%if(date_of_receipt==12)
    {
    out.println(value_of_fringe);%><%}%></td>
  </tr>
  <tr>
    <td width="127" height="38">Contribution To Provident Fund in Employer</td>
    <td width="61" height="38"><%if(date_of_receipt==1)
    {
    out.println(con_toprov);%><%}%></td>
    <td width="66" height="38"><%if(date_of_receipt==2)
    {
    out.println(con_toprov);%><%}%></td>
    <td width="60" height="38"><%if(date_of_receipt==3)
    {
    out.println(con_toprov);%><%}%></td>
    <td width="66" height="38"><%if(date_of_receipt==4)
    {
    out.println(con_toprov);%><%}%></td>
    <td width="67" height="38"><%if(date_of_receipt==5)
    {
    out.println(con_toprov);%><%}%></td>
    <td width="64" height="38"><%if(date_of_receipt==6)
    {
    out.println(con_toprov);%><%}%></td>
    <td width="64" height="38"><%if(date_of_receipt==7)
    {
    out.println(con_toprov);%><%}%></td>
    <td width="79" height="38"><%if(date_of_receipt==8)
    {
    out.println(con_toprov);%><%}%></td>
    <td width="79" height="38"><%if(date_of_receipt==9)
    {
    out.println(con_toprov);%><%}%></td>
    <td width="79" height="38"><%if(date_of_receipt==10)
    {
    out.println(con_toprov);%><%}%></td>
    <td width="103" height="38"><%if(date_of_receipt==11)
    {
    out.println(con_toprov);%><%}%></td>
    <td width="77" height="38"><%if(date_of_receipt==12)
    {
    out.println(con_toprov);%><%}%></td>
  </tr>
  <tr>
    <td width="127" height="19">Others</td>
    <td width="61" height="19"><%if(date_of_receipt==1)
    {
    out.println(other);%><%}%></td>
    <td width="66" height="19"><%if(date_of_receipt==2)
    {
    out.println(other);%><%}%></td>
    <td width="60" height="19"><%if(date_of_receipt==3)
    {
    out.println(other);%><%}%></td>
    <td width="66" height="19"><%if(date_of_receipt==4)
    {
    out.println(other);%><%}%></td>
    <td width="67" height="19"><%if(date_of_receipt==5)
    {
    out.println(other);%><%}%></td>
    <td width="64" height="19"><%if(date_of_receipt==6)
    {
    out.println(other);%><%}%></td>
    <td width="64" height="19"><%if(date_of_receipt==7)
    {
    out.println(other);%><%}%></td>
    <td width="79" height="19"><%if(date_of_receipt==8)
    {
    out.println(other);%><%}%></td>
    <td width="79" height="19"><%if(date_of_receipt==9)
    {
    out.println(other);%><%}%></td>
    <td width="79" height="19"><%if(date_of_receipt==10)
    {
    out.println(other);%><%}%></td>
    <td width="103" height="19"><%if(date_of_receipt==11)
    {
    out.println(other);%><%}%></td>
    <td width="77" height="19"><%if(date_of_receipt==12)
    {
    out.println(other);%><%}%></td>
  </tr>
  <tr>
    <td width="127" height="19">Sub Total</td>
    <td width="61" height="19"><%if(date_of_receipt==1)
    {
    out.println(sub_total);%><%}%></td>
    <td width="66" height="19"><%if(date_of_receipt==2)
    {
    out.println(sub_total);%><%}%></td>
    <td width="60" height="19"><%if(date_of_receipt==3)
    {
    out.println(sub_total);%><%}%></td>
    <td width="66" height="19"><%if(date_of_receipt==4)
    {
    out.println(sub_total);%><%}%></td>
    <td width="67" height="19"><%if(date_of_receipt==5)
    {
    out.println(sub_total);%><%}%></td>
    <td width="64" height="19"><%if(date_of_receipt==6)
    {
    out.println(sub_total);%><%}%></td>
    <td width="64" height="19"><%if(date_of_receipt==7)
    {
    out.println(sub_total);%><%}%></td>
    <td width="79" height="19"><%if(date_of_receipt==8)
    {
    out.println(sub_total);%><%}%></td>
    <td width="79" height="19"><%if(date_of_receipt==9)
    {
    out.println(sub_total);%><%}%></td>
    <td width="79" height="19"><%if(date_of_receipt==10)
    {
    out.println(sub_total);%><%}%></td>
    <td width="103" height="19"><%if(date_of_receipt==11)
    {
    out.println(sub_total);%><%}%></td>
    <td width="77" height="19"><%if(date_of_receipt==12)
    {
    out.println(sub_total);%><%}%></td>
  </tr>
  <tr><td width="127" height="19">Deduction

</tr>
<tr>
    <td width="127" height="57">Contribution To Provident Fund In Employer</td>
    <td width="61" height="57"><%if(date_of_receipt==1)
    {
    out.println(ded_cont_prov_employer);%><%}%></td>
    <td width="66" height="57"><%if(date_of_receipt==2)
    {
    out.println(ded_cont_prov_employer);%><%}%></td>
    <td width="60" height="57"><%if(date_of_receipt==3)
    {
    out.println(ded_cont_prov_employer);%><%}%></td>
    <td width="66" height="57"><%if(date_of_receipt==4)
    {
    out.println(ded_cont_prov_employer);%><%}%></td>
    <td width="67" height="57"><%if(date_of_receipt==5)
    {
    out.println(ded_cont_prov_employer);%><%}%></td>
    <td width="64" height="57"><%if(date_of_receipt==6)
    {
    out.println(ded_cont_prov_employer);%><%}%></td>
    <td width="64" height="57"><%if(date_of_receipt==7)
    {
    out.println(ded_cont_prov_employer);%><%}%></td>
    <td width="79" height="57"><%if(date_of_receipt==8)
    {
    out.println(ded_cont_prov_employer);%><%}%></td>
    <td width="79" height="57"><%if(date_of_receipt==9)
    {
    out.println(ded_cont_prov_employer);%><%}%></td>
    <td width="79" height="57"><%if(date_of_receipt==10)
    {
    out.println(ded_cont_prov_employer);%><%}%></td>
    <td width="103" height="57"><%if(date_of_receipt==11)
    {
    out.println(ded_cont_prov_employer);%><%}%></td>
    <td width="77" height="57"><%if(date_of_receipt==12)
    {
    out.println(ded_cont_prov_employer);%><%}%></td>
  </tr>
  <tr>
    <td width="127" height="44">Contribution To Provident Fund In Employee</td>
    <td width="61" height="44"><%if(date_of_receipt==1)
    {
    out.println(ded_cont_prov_emplee);%><%}%></td>
    <td width="66" height="44"><%if(date_of_receipt==2)
    {
    out.println(ded_cont_prov_emplee);%><%}%></td>
    <td width="60" height="44"><%if(date_of_receipt==3)
    {
    out.println(ded_cont_prov_emplee);%><%}%></td>
    <td width="66" height="44"><%if(date_of_receipt==4)
    {
    out.println(ded_cont_prov_emplee);%><%}%></td>
    <td width="67" height="44"><%if(date_of_receipt==5)
    {
    out.println(ded_cont_prov_emplee);%><%}%></td>
    <td width="64" height="44"><%if(date_of_receipt==6)
    {
    out.println(ded_cont_prov_emplee);%><%}%></td>
    <td width="64" height="44"><%if(date_of_receipt==7)
    {
    out.println(ded_cont_prov_emplee);%><%}%></td>
    <td width="79" height="44"><%if(date_of_receipt==8)
    {
    out.println(ded_cont_prov_emplee);%><%}%></td>
    <td width="79" height="44"><%if(date_of_receipt==9)
    {
    out.println(ded_cont_prov_emplee);%><%}%></td>
    <td width="79" height="44"><%if(date_of_receipt==10)
    {
    out.println(ded_cont_prov_emplee);%><%}%></td>
    <td width="103" height="44"><%if(date_of_receipt==11)
    {
    out.println(ded_cont_prov_emplee);%><%}%></td>
    <td width="77" height="44"><%if(date_of_receipt==12)
    {
    out.println(ded_cont_prov_emplee);%><%}%></td>
  </tr>
  <tr>
    <td width="127" height="31">Tds</td>
    <td width="61" height="31"><%if(date_of_receipt==1)
    {
    out.println(tds);%><%}%></td>
    <td width="66" height="31"><%if(date_of_receipt==2)
    {
    out.println(tds);%><%}%></td>
    <td width="60" height="31"><%if(date_of_receipt==3)
    {
    out.println(tds);%><%}%></td>
    <td width="66" height="31"><%if(date_of_receipt==4)
    {
    out.println(tds);%><%}%></td>
    <td width="67" height="31"><%if(date_of_receipt==5)
    {
    out.println(tds);%><%}%></td>
    <td width="64" height="31"><%if(date_of_receipt==6)
    {
    out.println(tds);%><%}%></td>
    <td width="64" height="31"><%if(date_of_receipt==7)
    {
    out.println(tds);%><%}%></td>
    <td width="79" height="31"><%if(date_of_receipt==8)
    {
    out.println(tds);%><%}%></td>
    <td width="79" height="31"><%if(date_of_receipt==9)
    {
    out.println(tds);%><%}%></td>
    <td width="79" height="31"><%if(date_of_receipt==10)
    {
    out.println(tds);%><%}%></td>
    <td width="103" height="31"><%if(date_of_receipt==11)
    {
    out.println(tds);%><%}%></td>
    <td width="77" height="31"><%if(date_of_receipt==12)
    {
    out.println(tds);%><%}%></td>
  </tr>

  <tr>
    <td width="127" height="25">Any Other Deduction</td>
    <td width="61" height="25"><%if(date_of_receipt==1)
    {
    out.println(anyothrded);%><%}%></td>
    <td width="66" height="25"><%if(date_of_receipt==2)
    {
    out.println(anyothrded);%><%}%></td>
    <td width="60" height="25"><%if(date_of_receipt==3)
    {
    out.println(anyothrded);%><%}%></td>
    <td width="66" height="25"><%if(date_of_receipt==4)
    {
    out.println(anyothrded);%><%}%></td>
    <td width="67" height="25"><%if(date_of_receipt==5)
    {
    out.println(anyothrded);%><%}%></td>
    <td width="64" height="25"><%if(date_of_receipt==6)
    {
    out.println(anyothrded);%><%}%></td>
    <td width="64" height="25"><%if(date_of_receipt==7)
    {
    out.println(anyothrded);%><%}%></td>
    <td width="79" height="25"><%if(date_of_receipt==8)
    {
    out.println(anyothrded);%><%}%></td>
    <td width="79" height="25"><%if(date_of_receipt==9)
    {
    out.println(anyothrded);%><%}%></td>
    <td width="79" height="25"><%if(date_of_receipt==10)
    {
    out.println(anyothrded);%><%}%></td>
    <td width="103" height="25"><%if(date_of_receipt==11)
    {
    out.println(anyothrded);%><%}%></td>
    <td width="77" height="25"><%if(date_of_receipt==12)
    {
    out.println(anyothrded);%><%}%></td>
  </tr>
  <tr>
    <td width="127" height="28">Sub Total</td>
    <td width="61" height="28"><%if(date_of_receipt==1)
    {
    out.println(subtot);%><%}%></td>
    <td width="66" height="28"><%if(date_of_receipt==2)
    {
    out.println(subtot);%><%}%></td>
    <td width="60" height="28"><%if(date_of_receipt==3)
    {
    out.println(subtot);%><%}%></td>
    <td width="66" height="28"><%if(date_of_receipt==4)
    {
    out.println(subtot);%><%}%></td>
    <td width="67" height="28"><%if(date_of_receipt==5)
    {
    out.println(subtot);%><%}%></td>
    <td width="64" height="28"><%if(date_of_receipt==6)
    {
    out.println(subtot);%><%}%></td>
    <td width="64" height="28"><%if(date_of_receipt==7)
    {
    out.println(subtot);%><%}%></td>
    <td width="79" height="28"><%if(date_of_receipt==8)
    {
    out.println(subtot);%><%}%></td>
    <td width="79" height="28"><%if(date_of_receipt==9)
    {
    out.println(subtot);%><%}%></td>
    <td width="79" height="28"><%if(date_of_receipt==10)
    {
    out.println(subtot);%><%}%></td>
    <td width="103" height="28"><%if(date_of_receipt==11)
    {
    out.println(subtot);%><%}%></td>
    <td width="77" height="28"><%if(date_of_receipt==12)
    {
    out.println(subtot);%><%}%></td>
  </tr>
  <tr>
    <td width="127" height="37">Net Amount</td>

    <td width="66" height="37"><%if(date_of_receipt==1)
    {
    out.println(netamnt);%><%}%></td>
    <td width="60" height="37"><%if(date_of_receipt==2)
    {
    out.println(netamnt);%><%}%></td>
    <td width="66" height="37"><%if(date_of_receipt==3)
    {
    out.println(netamnt);%><%}%></td>
    <td width="67" height="37"><%if(date_of_receipt==4)
    {
    out.println(netamnt);%><%}%></td>
    <td width="64" height="37"><%if(date_of_receipt==5)
    {
    out.println(netamnt);%><%}%></td>
    <td width="64" height="37"><%if(date_of_receipt==6)
    {
    out.println(netamnt);%><%}%></td>
    <td width="79" height="37"><%if(date_of_receipt==7)
    {
    out.println(netamnt);%><%}%></td>
    <td width="79" height="37"><%if(date_of_receipt==8)
    {
    out.println(netamnt);%><%}%></td>
    <td width="79" height="37"><%if(date_of_receipt==9)
    {
    out.println(netamnt);%><%}%></td>
    <td width="103" height="37"><%if(date_of_receipt==10)
    {
    out.println(netamnt);%><%}%></td>
    <td width="77" height="37"><%if(date_of_receipt==11)
    {
    out.println(netamnt);%><%}%></td> <td width="77" height="37"><%if(date_of_receipt==12)
    {
    out.println(netamnt);%><%}%></td>
  </tr>
<%}%></td></tr></table>

thanks in advance

Well, first of all, use a Connection Pool. Don't make a connection everytime the JSP is called, that is just plain bad practice.

Secondly, move all this stuff out into a Bean where it should be. All this Scriptlet stuff is wholly unmanageable.

And seem to be reading the data a row at a time, but want to fill the table a column at a time. And you seem to be doing this by outputting, essentially, an entire table for each row with only one column being populated. So I need to ask why you thought that would work?

You need to read all of the data storing it into a multidimensional array to arrange it properly, then you can output the array a "row" at a time and get the display right. But that is the last I am going to say on the topic until you get rid of all this scriptlet junk.

Thanks for reply
Can u give some more ideas idea regarding it.actually i m new to Jsp.Please Give some more information how to do it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.