Forums Register Login

Problem while displaying the LIst in JSP

+Pie Number of slices to send: Send
Hi All,

I have a problem while displaying the List in the jsp.
Say suppose i have 50 records in the DB and i want to display 10-10 records in the jsp with 'Next' and 'Previous' button.
for this scenario i do not want to keep the whole list in the cache. I want to query the DB each time when user click on the 'Next' or 'Previous' Button.

Please someone suggest me, how to achieve this in jsp.
+Pie Number of slices to send: Send
Just put the limit in the query like

SELECT * FROM <table_name> LIMIT 1,10

Next time the query will look like:

SELECT * FROM <table_name> LIMIT 11,20

and so on.

Now where to store the information, what level of paginated page is on
display. You can keep this information on the Session object.
+Pie Number of slices to send: Send
See the JSP FAQ for a discussion of this.
+Pie Number of slices to send: Send
Hi,
the query suggested by you is not working in oracle.
Can somebody suggedt any other way to implement this.

Thanks in advance

Shishir
+Pie Number of slices to send: Send
Oracle has a system attribute ROWNUM for each record returned. A query that
only returns the first 20 records would look like the one in the example.

select col from <table name> where rownum<=20;


See this link at JavaRanch
+Pie Number of slices to send: Send
"select * from ( select row_.*, rownum rownum_ from (select * from ( select row_.*, rownum rownum_ from (" + yourSql + " ) row_ where rownum <= " + endIdx + ") where rownum_ >" + beginIdx ) row_ where rownum <= " + endIdx + ") where rownum_ >" + beginIdx
+Pie Number of slices to send: Send
Sorry, there's some mistake in my first reply.

In the case of Oracle, use this:

"select * from (select row_.*, rownum rownum_ from (" + yourSql + " ) row_ where rownum <=20 where rownum_ >10"
+Pie Number of slices to send: Send
There must be something wrong with me today!
A ")" should be following "rownum <=20".
+Pie Number of slices to send: Send
Howdy fransis lin,

You can edit your post clicking this link:

To edit your first most post in this thread click here
We find this kind of rampant individuality very disturbing. But not this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1102 times.
Similar Threads
JSP Pagination
how to display Result set pagewise
Get the records by portion from a database
Retrieving and Presenting huge data
Which feature of Struts suits this problem better ?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 17:19:35.