wood burning stoves 2.0*
The moose likes JSP and the fly likes dynamic pagging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "dynamic pagging" Watch "dynamic pagging" New topic
Author

dynamic pagging

malik ge
Ranch Hand

Joined: May 13, 2011
Posts: 69
Hi,
I want to know how to generate Dynamic paging in jsp.

By doing this
I can limit the data to show first 5 records from the database , but how can I show

... page numbers at the end of the table (according to the records in the database)

and by clicking 2 the next 5 records are shown from the database and so on.

Any help..
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

"pagging"? Please proof-read before hitting submit.

malik ge wrote:Hi,
I want to know how to generate Dynamic paging in jsp.

By doing this
I can limit the data to show first 5 records from the database ,

Yes, in fact there is a JspFaq entry on this subject.

but how can I show

... page numbers at the end of the table (according to the records in the database)

Determine how many total records there are irrespective of paging, divide by the page size, and you know the number of pages. Then you create a link for each page number, passing the page number as a query or path parameter.

Easy as pie.

and by clicking 2 the next 5 records are shown from the database and so on.

Any help..


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
malik ge
Ranch Hand

Joined: May 13, 2011
Posts: 69
For example there are 15 records in the database, and I can put the page number as follow , and send the page number as well.


Then how when page 2 is clicked, the next 5 records are shown?
I didn't understand that
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Your database query will be adjusted to give you the "slice" that gives you the second "page" of records.

You already posted the SQL statement to obtain a slice, do you not understand how that works? If not, research how to use the LIMIT* clause to obtain any "page" of data you want.

Did you read the JspFaq?




* This is database-specific (this is MySQL, no?), so you need to look up how to do this for different databases if you move to a different database.
malik ge
Ranch Hand

Joined: May 13, 2011
Posts: 69
On JspFaq
I. Repeat the query for each new request.
Algorithm:
Client requests page 1
Execute the query
Return rows for page 1
Client requests page 2
Execute the query
Skip rows for page 1
Return rows for page 2


If I am not wrong, then when page 2 is clicked then I have to run:

If page 3 is clicked then:

???
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Could be. I'm not familiar enough with MySQL's LIMIT clause to know if that's the right order. Consult the documentation.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: dynamic pagging
 
Similar Threads
view of records in jtable
retrieving data pagewise
sql for select intermediate rows
sending large data to server
Help Regarding using Access Database in java