JSP Array Display by PAGE (inber original)

Source: Internet
Author: User

<%
/*
Inberkong
Inber520@yahoo.com.cn
QQ: 27096282
Array paging technology
Arraytest. jsp

*/
String [] contentarray = {};
Contentarray = new string [125];
For (INT I = 0; I <125; I ++)
{
Contentarray [I] = "ayyayvalue" + String. valueof (I );
}

Int introwcount; // a total of 125 records
Int intpage =-1; // page number to be displayed
Int intpagecount; // the total number of pages.
Int intpagesize; // The number of records displayed on one page is 6.
Intpagesize = 6;

If (request. getparameter ("pages") = NULL)
Intpage = 1;
Else
Intpage = integer. parseint (request. getparameter ("pages "));

Introwcount = 125; // total number of records
// Calculate the total number of pages
Intpagecount = (introwcount + intPageSize-1)/intpagesize;

Int startrecord = (intPage-1) * intpagesize;
Int endrecord = (intpage * intPageSize-1 );
While (startrecord <= endrecord & startrecord <= (intRowCount-1 ))
{
Out. Print ("contentarray [" + startrecord + "]:" + contentarray [startrecord] + "<br> ");
Startrecord = startrecord + 1;
}
%>
<Table width = "77%" Height = "15" border = "0" align = "center" cellpadding = "1" cellspacing = "0">
<Tr>
<TD width = "43%" bgcolor = "# cccccc"> </TD>
<TD width = "57%" bgcolor = "# cccccc"> <a href = "? Pages = 1 "> homepage </a>
 
<%
If (intPage-1) <1)
Out. Print ("Previous Page ");
Else
Out. Print ("<a href = '? Pages = "+ (intPage-1) +" '> previous page </a> ");
%>
 
<%
If (intpage <intpagecount)
Out. Print ("<a href = '? Pages = "+ (intpage + 1) +" '> next page </a> ");
Else
Out. Print ("next page ");
%>
& Nbsp; <a href = '? Pages = <% = intpagecount %> '> last page </a> </TD>
</Tr>
</Table>

 

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.