Displaying 1000 records per page.

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.

Thanks
Suketu
suketu9Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

fargoCommented:
Hi,

have a look here
http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_21777860.html

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.

fargo

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fargoCommented:
Other options are

display tags
http://displaytag.sourceforge.net/11/

Examples and tutorials are all there.

For the previous post, here is the links
Use Pagination tag
http://jsptags.com/tags/navigation/pager/index.jsp

Documentation on it
http://jsptags.com/tags/navigation/pager/index.jsp

regards,
fargo
jessegivyDeveloperCommented:
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?

Sincerely,

Jesse
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

suketu9Author Commented:
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!
suketu9Author Commented:
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 jsptags.com 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.

Thanks
fargoCommented:
Hi,

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
http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_21777860.html

In case of any questions, ask back.

fargo
massricoCommented:
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
      if(request.getParameter("nCurrentPage")!=null)
            nCurrentPage = Integer.parseInt(request.getParameter("nCurrentPage"));  
        else
                nCurrentPage = 1;

      
      // 1- get the Number of the Records
      rs = statement.executeQuery("SELECT  count(*) as nRec FROM viajes");
      rs.next();
      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
      


      
      
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.