• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Splitting a large table into multiple JSP pages

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a problem with presenting my data on my JSP.

My struts app pulls some data from the DB and presents it in a table on a jsp page.
because the records may range from 1 to 1000++, depending on the user's query.

i am wondering if there is anyway, to
"save the table" and spread the data (let's say every 50 rows) on the jsp.

The user will click a "next" button to see the next 50 rows until the end.

Preferbly, I would prefer to do the SQL query once, and post-process the data, rather than
executing the SQL query n times.

Wonder if you guys can point to me the general direction of a solution.

Thanks!
 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
one way i think would be to store the values returned by the query in a session variable.
disadvantage is storage space for the session.
will come back with a better solution.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Have a variable page.

While calling the presentation page for first page call it with value 0 for this variable. Then after fetching the resultset move record cursor page * 50 times using looping. Then display ur next set of 50 records.

Then use next butoon to call the same page with (page + 1) value for this variable.

Following is a sample code for the above said :

ResultSet rs_sample;

int toMove = Integer.ParseInt(request.getParameter("page"));

//to move record cursor to point particular page's start record

for(i=1;tomove*50;i++)
rs_sample.next();

int count = 1;

while(rs_sample.next && count <= 50)
{
// display records in your own format may be 1 record per row
}

Call samepagename.jsp with page=(toMove-1) for previous page

Call samepagename.jsp with page=(toMove+1) for next page

Hope this could be useful for u.

Bye,

B.Prakash
 
Mervin Chan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Prakash:

Thanks man.

It was quite useful.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic