A class of pagination and its calling method implemented with JSP

Source: Internet
Author: User

Pagect.java-Paging class
/*
@version ***********
Created on June 25, 2001, 14:41
**************************************
*/
Package VOD;
Import java.sql.*;
Import java.util.*;

public class Pagect
{
Private long L_start; Start recording
Private long l_end; End record
Private long l_curpage; Current page
Private long l_totalnum;//total record number
private int int_num=5; 10 Records per page
Private long l_totalpage; Total number of pages

public void Init (Long currentpage,long totalnum)
{
L_curpage = CurrentPage;
L_totalnum = Totalnum;

if (currentpage>=0)
{
if (currentpage>= (long) Math.ceil (double) l_totalnum/(double) int_num)
L_curpage = (long) Math.floor (double) l_totalnum/(double) int_num);
Else
L_curpage = CurrentPage;
}
Else
{
l_curpage = 0;
}
L_start = L_curpage * INT_NUM;
L_end = L_start + int_num;
if (L_end > L_totalnum)
L_end = L_totalnum;
L_totalpage = (long) Math.ceil (double) l_totalnum/(double) int_num);
}
Public long Getcurpage ()
{
return l_curpage;
}
Public long Getprepage ()
{
if (l_curpage-1>=0)
{
return l_curpage-1;
}
Else
{
return 0;
}
}
Public long Getnextpage ()
{
if (l_curpage+1<=l_totalpage)
{
return l_curpage+1;
}
Else
{
return l_totalpage;
}
}
Public long Gettotalnum ()
{
return l_totalnum;
}
Public long Gettotalpage ()
{
return l_totalpage;
}
Public long Getstart ()
{
return l_start;
}
Public long Getend ()
{
return l_end;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.