Question

recently i created a table to display all the information inside my database but it wont go so well.

here is my code

reveneuPage.jsp

<table class="table table-bordered table-striped table-hover">
                        <thead>
                        <th> Date </th>
                        <c:forEach var="revcodes" items="${revcodeList}">
                        <th>${revcodes.revcode}</th>
                        </c:forEach>
                        <!--<th> Total </th>-->
                        </thead>

                          <c:forEach var="revcodedate" items="${revcodeList}">
                        <tr>
                            <td>${revcodedate.date}</td>
                            <c:forEach var="revcodeAmount" items="${revcodeList}">
                                <td>${revcodeAmount.amount}</td>
                            </c:forEach>



                        </tr>
                        </c:forEach>
                    </table>

revenuereport.java

String year = request.getParameter("year");
            String month = request.getParameter("month");
            a = new Db();
            String query = "SELECT\n" +
                            "  user_payment.revcode,\n" +
                            "  user_payment.date,\n" +
                            "  user_payment.amount,\n" +
                            "   revcode.revcodeactual\n" +
                            "FROM\n" +
                            "  user_payment, revcode\n" +
                            "WHERE\n" +
                            "  YEAR(user_payment.date) = '"+year+"' AND MONTH(user_payment.date) = '"+month+"' \n" +
                            "   and user_payment.revcode = revcode.revcodeactual\n" +
                            "Group By \n" +
                            "  user_payment.revcode, date\n" +
                            "Order By\n" +
                            "  user_payment.date ASC";

            resultSet = a.sqlQuery(query);
            while(resultSet.next()){
                revcodeList.add(new revcodes(
                        resultSet.getInt("revcodeactual"),
                        resultSet.getDate("date"),
                        resultSet.getDouble("amount")
                        ));

            }

            request.setAttribute("revcodeList", revcodeList);
            RequestDispatcher rd = request.getRequestDispatcher("revenuePage.jsp");
            rd.forward(request, response);

and after i execute this code, i got the iteration of 25 rows of the same date n revcodes.. what should i do? is my query wrongly structured? or i misused the object passing in servlet response and request?

i upload my screenshot here

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top