Displaying 1000 records per page.

Posted on 2006-03-28
Last Modified: 2010-08-05
Hi Experts,
Currently we are displaying more than 1000 records per page in JSP and its taking around 25 minutes to display the page. So we want to only display 1000 per page and do prev or next for other records. Can anyone provide me with code to do this. I did search the forum but I got confused. If someone can provide step by step then it would be great. I am totally new to this and I have to get this done by Friday.

Question by:suketu9
    LVL 11

    Accepted Solution


    have a look here

    but i suspect, if the retrieval time of 1000 records is large, the above will not work.

    Other option is to use the paging at the Database level. There is no such code available for it and u have to implement it on your own.

    LVL 11

    Expert Comment

    Other options are

    display tags

    Examples and tutorials are all there.

    For the previous post, here is the links
    Use Pagination tag

    Documentation on it

    LVL 12

    Expert Comment

    What kinda data do you have that it takes 25 minutes, or are you on a 14400 dial up connection ;)

    If there's a bunch of large images, or files, then it could be a solution to show them as attachments.  How many fields are we talking about?



    Author Comment

    Its just displays some data in the table format in jsp but the table has around 30000 plus data in it which it tries to display at once. So we want to display 1000 per page instead of all 30000 at once. Thanks!

    Author Comment

    I am using DB2 as my Database. So please let me know what do i need to do to display 1000 per page in jsp. Please provide me with code to better understand. I went to but dont understand how to implement it in my code and what else I have to implement beside the page tag library. If anyone can tell me how to implement page tag library that would be great.

    LVL 11

    Expert Comment


    I asked you to take a look at the following link, i explained clearly what to do to make use of jsptags pager taglib.

    have a look here

    In case of any questions, ask back.


    Assisted Solution

    Hi All

    I faced this situation before and I Solved as the Following

                      int nRecords =0, nPages =0, nFrom =0, nTo =0, nCurrentPage =1, nRecordsPerPage =1000;  

            // 0- Get Actual Current Page
                nCurrentPage = Integer.parseInt(request.getParameter("nCurrentPage"));  
                    nCurrentPage = 1;

          // 1- get the Number of the Records
          rs = statement.executeQuery("SELECT  count(*) as nRec FROM viajes");
          nRecords = rs.getInt("nRec");
          // 2- get total pages
          nPages= (nRecords/nRecordsPerPage) + 1;
          // 3- set Page Starting Record
          nFrom = (nCurrentPage-1) * nRecordsPerPage ;
            // 4- Show Rows
          rs = statement.executeQuery("SELECT viajes.ID, viajes.titulo FROM viajes where GROUP BY ID DESC LIMIT "+ nFrom + "," + nRecordsPerPage );      


    and for Next and Previous Buttons

    *) Previous Button
                             <% if (nCurrentPage>1) {%><a href="ofertas.jsp?nCurrentPage=<%=(nCurrentPage-1)%>"></a><%}%>

    *) Next Button
                            <% if (nPages > nCurrentPage) {%><a href="ofertas.jsp?nCurrentPage=<%=(nCurrentPage-1)%>"></a><%}%>

    Khaled Ahmed


    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
    Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now