• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Displaying search data

 
Martin Lira
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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?

Thanks
Martin
 
Jason Milliron
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic