Basically is not coming from the same query, and also for now I don't want to touch the query b/c somebody else may invoke it. So on the jsp now I got the whole Array List of data sorted, I just need some sample code that do the paging using scriplet in JSP.
JSTL's forEach tag has begin and end attributes. In your form or hyperlinks, send the desired items from the list.
You will either need to store the whole list in session which could result in a lot of memory consumption if the results are large or, read the entire result from the database with each call and ignore all but the rows that you want to show. This can also be inefficient if the database is returning large result sets.
Regardless of how you are obtaining the data, the paging should not be happening in the UI layer. Rather your model should have an API that allows the UI to ask for the records for a particular page, which should return only the relevant records.
This not only keeps your UI code "cleaner", but also allows you to change the details at any later date on how the page of data is obtained.
Doing this sort of thing in the UI is a poor practice and should be aoivded.
Joined: Apr 04, 2002
Thank you Pallavi Srivastava; I think that what I am looking for and try to customize it. Thanks again.
Joined: Dec 22, 2006
Thank you Bear for the tip.I am able to develop logic of the application but still weak at architect level.As you said, I will make a pagination component and remove the mess from front end.
Joined: Apr 04, 2002
That's is a good suggestion from Bear. But sometimes, the application is not in the new redesign mode, sometimes you need to modified the OLD code therefore, there is nothing much in design or architech that you can change in the mean time while time is in constrant.
Ah yes, how many times have I heard management say that? And while it may appear to be a logical conclusion, frequently it is not. Sometimes you'll spend a far greater amount of time trying to get a poorly constructed system to work the way you want it to than it would take to refactor the whole thing.
Management tends to perfer the former though because, even if it is buggy, they can see something, which gives them the illusion of progress. Whereas a refactor gives them the feeling that nothing is happening.
But this probably belongs in the process forum... [ June 08, 2007: Message edited by: Bear Bibeault ]