File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Displaying search data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Displaying search data" Watch "Displaying search data" New topic

Displaying search data

Martin Lira
Ranch Hand

Joined: May 26, 2004
Posts: 97
I have an application that lists cities in states.
For example in State=Texas I will have links A B C D E F G.....X

On each link it will display cities starting by that alphabet.
I want to restrict cities being displayed by 10 on each page and provide a next,previous functionality.

I am using JDBC with SQL Server as my backend. Please give me suggestions how i can implement this in a JSP front end web application?

Jason Milliron

Joined: Jan 25, 2004
Posts: 22
If the cities data doesn't change often, store the cities in some type of List. Each time a user clicks a different letter, such as B or M, goto the db and populate a new list of cities ordered asc for all the M cities. On the first display of the newly clicked M, display the first 10 cities in the list. You know at this point you won't need a previous because it's the first 10 cities. Check to see if an 11th entry exist, and if so, display the next button. On the next button, pass the index of the last city on the screen, such as 10. When the user clicks the next button, the user will be taken to the same page, but now start the index at (10+1) = 11 and show up to 10 more cities. If there are more citeis like 21-30, show the next button, also now if the index you passed, 10 is > than the max number of cities in the list, show the previous button. I hope this helps. Let me know if this is what you are looking for.
I agree. Here's the link:
subject: Displaying search data
It's not a secret anymore!