Discussions

Web tier: servlets, JSP, Web frameworks: need paging functionality (first/next,last etc)

  1. Hai guys,
    i want to implement a paging(next,first,last links) functionality in my JSP (which can control displaying 1000's of records to show in order of 10 or 15 in a page and next in other page). whatz the best technique i can use.
    plz help me.
    regards,
    Mahesh
  2. Hai guys,i want to implement a paging(next,first,last links) functionality in my JSP (which can control displaying 1000's of records to show in order of 10 or 15 in a page and next in other page). whatz the best technique i can use.plz help me.regards,Mahesh

    Hi Mahesh,

    Assuming that you are using Oracle, one of the ways to do paging is to:

    first: figure out the total number of records that need to be displayed:

    "total_records = select count(column_name) from table"

    second: figure out number of records to be displayed on one page

    "lets say: records_per_page = 15"

    third: calculate the total number of pages

    "total_number_of_pages = total_records/records_per_page"

    fourth: display the records by using the "rownum" feature supported by oracle.

    "select column_name from table where rownum between x and y"


    hope that helps....

    Sachin
  3. Hi Mahesh,
     You may try out a very nice and neat custom tag library viz. "displayTag" which you will find at:
    http://www.displaytag.org/index.jsp
    Just look at the documentation/examples, maybe that's what you were looking for!! You will additionally get Export to Excel/XML/CSV, sorting, grouping functionalities, too.
    -Prasad
  4. I am using JSF and SUN's JAVA Creator and it is quite easy:
    - connect the dadaTable with your collection of beans
    - add the paging

    about 5 clicks of mouse

    if you have collection of entity beans than the "add, update, delete" is also very quick to implement

    but it is OK only for small amount of data; for bigger tables I implement the DAO by JDBC; then it requires little bit more coding ...
  5. ValueList[ Go to top ]

    valuelist.sf.net
  6. See for example Page taglib in Coldtags suite:
    http://www.servletsuite.com/jsp.htm