Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How i can create multiple pages dinamic with a servlet ?

 
Federico Delgado
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi people:
I'm a beginner developer JSP/Java and i need a help to create some application for display the result of my search in DB in multiple pages ...
Like a forum, with previus and next stuff ...
Someone can help me ?!
Thanks !
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not aware of a safe, generalized way to do this. I've done several apps where we retrieved data from a backend service and limited the number of rows that would fit in one response. If the user wants to see more data, the client has to ask for the "next" set of rows.
If the data is not changing all the time, this isn't too hard. We have used a row number so the client request is give me rows 51-75, 76-100, etc. The server repeats the query used the first time, skips n rows, and gives back the next batch. We have also used the last primary key retrieved - give me 25 rows starting with the first key > this one. Either of these runs into trouble if the result set is changing - more rows or fewer rows or different rows than it had last time. Page forward might skip some rows. Page forward and backward might not give you the same results you saw before.
I suppose the surest way to give the user a self-consistent view is to retrieve the whole superset and store it somewhere, then page forward and backward through the private copy. That blows away the notion of a stateless server, tho.
 
Federico Delgado
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the idea ... But you have a sample code for that ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic