Meaningless Drivel is fun!
The moose likes JSP and the fly likes how to use Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "how to use "previous"  "next" buttons in a JSP page" Watch "how to use "previous"  "next" buttons in a JSP page" New topic

how to use "previous" "next" buttons in a JSP page

giri shetty

Joined: Jan 22, 2004
Posts: 27
Hi everybody can any one of u explain how to write a code for "next", ""previous" buttons ina jsp i will get only one record at a time if click "next' button i have to get next record and if i click "previous" button i have to get previous button.
please give me a hint
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

Welcome to the Ranch giri!
You'll find this forum a great place to seek help on JSP pages, and there aren't many rules you'll have to worry about, but one is that proper names are required. Please take a look at the JavaRanch Naming Policy and change your display name to match it.
In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.
In addition, JavaRanch is a community of people from all over the world, many of who are not native English speakers. While using abbreviations like "u" instead of spelling out "you" is convenient when text messaging your friends on a cell phone or in a chat room, it presents an extra challenge to those that are already struggling with English. I would like to ask for your help in making the content of JavaRanch a little easier to read for everybody that visits here by not abbreviating these words.
JSP Forum Bartender

[Asking smart questions] [About Bear] [Books by Bear]
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
It will all depend on how your data is stored and retrieved. I have a simple site with a bunch of pictures of the area. When I generate a page to show the first picture, I generate HTML links for next & prior that include picture numbers. So when you're looking at picture 2 I generate:
<a href="samepage?num=1>Prior</a> <a href="samepage?num=3">Next</a>
You need to generate buttons instead of links, but if you know HTML that should not be too tough. Where I got lucky is that I knew the picture number and the picture count.
If you're getting data from a SQL query and trying to keep track of where you are in the query results, things get tricky in a hurry. Try this thread: Pagination for more options.
[ January 22, 2004: Message edited by: Stan James ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: how to use "previous" "next" buttons in a JSP page
It's not a secret anymore!