wood burning stoves 2.0*
The moose likes JSP and the fly likes Splitting a large table into multiple JSP pages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Splitting a large table into multiple JSP pages" Watch "Splitting a large table into multiple JSP pages" New topic
Author

Splitting a large table into multiple JSP pages

Mervin Chan
Greenhorn

Joined: Dec 03, 2004
Posts: 24
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!
Niki Nono
Ranch Hand

Joined: Mar 20, 2005
Posts: 256
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.


Life called,so here I am.<br />Cheers<br />Niki.:-)
Prakash Balasubramani
Greenhorn

Joined: Sep 09, 2005
Posts: 8
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

Joined: Dec 03, 2004
Posts: 24
Prakash:

Thanks man.

It was quite useful.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Splitting a large table into multiple JSP pages
 
Similar Threads
Using of Statement.setFetchSize
Different restults from Oracle and JDBC
JSP Pagin while reading the file contents
Retrieving a subset of rows with SQL
SQL databases