shishir choubey
,
Greenhorn
Oct 19, 2008 11:59:00
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.
Chandra Bhatt
,
Ranch Hand
Oct 19, 2008 12:04:00
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.
Bear Bibeault
,
Sheriff
staff
Oct 19, 2008 12:14:00
See the JSP FAQ for a discussion of this.
shishir choubey
,
Greenhorn
Oct 20, 2008 23:28:00
Hi, the query suggested by you is not working in oracle. Can somebody suggedt any other way to implement this. Thanks in advance Shishir
Chandra Bhatt
,
Ranch Hand
Oct 21, 2008 00:36:00
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
francis lin
,
Greenhorn
Oct 21, 2008 03:11:00
"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
francis lin
,
Greenhorn
Oct 21, 2008 03:17:00
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"
francis lin
,
Greenhorn
Oct 21, 2008 03:21:00
There must be something wrong with me today! A ")" should be following "rownum <=20".
Chandra Bhatt
,
Ranch Hand
Oct 21, 2008 14:03:00
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