0

I'm creating application where i'm showing list details to manager this details im fetching from database and dynamically show in table, All is working fine but only concern is i want to add pagination in page manager can see upto 5 records i google it but not get proper answer for better understand i added screenshot of dynamic table also

 <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <%@page import="java.sql.PreparedStatement"%>
    <%@page import="java.sql.SQLException"%>
    <%@page import="java.sql.DriverManager"%>
    <%@page import="java.sql.ResultSet"%>
    <%@page import="java.sql.Statement"%>
    <%@page import="java.sql.Connection"%>
    <%@page import="java.sql.*"%>
    <%@page import="java.time.LocalTime"%>
    <%@page import="java.time.LocalDate"%>
    <%@page import="java.text.*,java.util.Date"%>
    <%@page import="java.time.Duration"%>
    <%@page import="java.time.Instant"%>
    <%@page import="java.util.Scanner"%>
    <%@page import="weblogic.connection.java.Weblogic_connection" %>
      <link type="text/css" rel="stylesheet" href="Stylesheet.css">


      <%

              Connection connection = null;
    Statement statement = null;
    ResultSet resultSet = null;
    ResultSet resultSet2 = null;



            %>

    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>Employee and vendor approve Page</title>

          <link type="text/css" rel="stylesheet" href="Stylesheet.css">

        </head>
        <br>
        <div class="title">
      <header>
                    <span class="name" style="color:blue;font-style:italic;">EMPLOYEE APPROVE PAGE</span>   
                </header>
                </div>
        <form method="post">
             &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

            <input type="submit" name="btnVIEW_LOGIN" value="VIEW_LOGIN" class="button button2">
            <%
            String btnVIEW_LOGIN=request.getParameter("btnVIEW_LOGIN");
            String Manager_id1=request.getParameter("manager_id");
            if(btnVIEW_LOGIN!=null)
            {
              response.sendRedirect("SearchSheet.jsp");
               session.setAttribute("manager_id", Manager_id1);
            }

            %>
        </form>

        <body background="images\blue_background.jpg">

        <label class="logoutLblPos">
        <a href="Logout.jsp" align="left">LOGOUT</a>
        </label>
                 <%
                  Class.forName("oracle.jdbc.driver.OracleDriver");
              Connection con=DriverManager.getConnection("jdbc:oracle:thin:@172.18.114.213:1821:godb","sbigi_gtrg","Spacess");

                 %>


            <table border="1" align="center" background="images\blue-wallpaper-7.jpg">
                <span class="name" style="color:white;font-style:bold;">  For Task  Approve </span>
                 <tr bgColor="yellow">
                     <td><font color="Red">PROJECT_NAME</font> </td>
                    <td><font color="Red">HEADER</font></td>
                    <td><font color="Red">DESCRIPTION</font></td>
                    <td><font color="Red">Employee_id</font></td>
                     <td><font color="Red">Approve</font></td>
                     <td><font color="Red">Status</font></td>
                </tr>
                <%
                   statement=con.createStatement();
                String Sql1="SELECT PK.PROJECT_ID,PK.PROJECT_NAME,PK.HEADER,PK.DESCRIPTION,DK.EMPLOYEE_ID,PK.approve FROM EMPLOYEE_TASK PK inner join REGISTRATION_EMPLOYEE dk on dk.employee_id=pk.employee_id where dk.REPORTING_MANAGER_ID='"+Manager_id+"' and PK.approve='Pending'";
                resultSet2=statement.executeQuery(Sql1);
                while(resultSet2.next())     
    {
        String PROJECT_ID=resultSet2.getString("PROJECT_ID");

          %>

         <tr>


                  <td><font size="4"> <font color="white"><%=resultSet2.getString("PROJECT_NAME")%></font></font></td>
                  <td><font size="4"> <font color="white"><%=resultSet2.getString("HEADER")%></font></font></td>
                  <td><font size="4"> <font color="white"><%=resultSet2.getString("DESCRIPTION")%></font></font></td>
                  <td><font size="4"> <font color="white"><%=resultSet2.getString("EMPLOYEE_ID")%></font></font></td>
                  <td><font size="4"> <font color="white"><%=resultSet2.getString("APPROVE")%></font></font></td>
                  <td>
                      <a href="TaskListApprove.jsp?id=<%=resultSet2.getString("EMPLOYEE_ID")%>&PROJECT_ID_update=<%=PROJECT_ID%>"><B>UPDATE</b></a>

                </td>

          </tr>


    <%

        }
    }
    catch(Exception ex)
    {
                out.println("<html><body><script type=\"text/javascript\">"); 
               out.println("confirm('Session Expired Login again');");
     out.println("location='EmployeeLogin.html';");
               out.println("</script></body></html>"); 

    }


                %>
            </table>
                  </form>
              <div class="footer">
      <p>KBC &nbsp;&nbsp;</p>
    </div>
        </body>

    </html>

enter image description here

MT0
  • 143,790
  • 11
  • 59
  • 117
Atul
  • 11
  • 8
  • 1
    First, if you have posted username and password then delete your question and repost it as a new question with those details edited out. Second, use a parameterised query and not string concatenation in your prepared statement as this is just asking for SQL injection attacks. Thirdly, what version of Oracle are you using? If you are using Oracle 12 then you can use `OFFSET 5 FETCH NEXT 5 ROWS ONLY` syntax. – MT0 May 16 '18 at 07:59
  • Probably a duplicate of https://stackoverflow.com/q/470542/1509264 – MT0 May 16 '18 at 08:01
  • @MT0: thank you for reply for query side it is ok but im confuse how i can use pagination for this table? – Atul May 16 '18 at 08:07

0 Answers0