JSP Paging program code

Source: Internet
Author: User

JSP Paging program code
<%@ page contenttype= "text/html; charset=gb2312 "language=" java "import=" java.sql.* "errorpage=" "%>"
<% @include file = ". /inc/chkpwd.jsp "%>
<% @include file= ". /db.jsp "%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta name= "Robots" content= "Noindex,nofollow"/>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> Article Management </title>
<link href= "Style.css" rel= "stylesheet" type= "Text/css"/>

<body>

<table width= "98%" height= "77%" border= "0" cellpadding= "0" cellspacing= "0" >
<tr class= "STYLE1" >
&LT;TD width= "100% height=" background= "images/admin_bg_1.gif" ><strong><font color= "#FFFFFF" >-- <span class= "STYLE1" > Content Management </span></font></strong></td>
</tr>
<tr>
&LT;TD colspan= "Ten" >
</td>
</tr>

<tr class= "title" >
&LT;TD height= "background=" Images/admin_bg_1.gif "class=" "T2" >|&nbsp;
<%
String op;
String id = request.getparameter ("id");
OP = Request.getparameter ("op");
if (op==null) {
OP = "my";
}
if (Op.equals ("del") && id!=null) {
string bbb = new String (Request.getparameter ("Bigclassname"). GetBytes ("Iso8859_1"));
Statement stmt_channeldel=conn.createstatement ();
String sqldel= "Delete from hl_news where id=" + ID;
int shan=stmt_channeldel.executeupdate (Sqldel);
if (shan>0)
{
Out.print ("<script type=" Text/javascript "> Alert (") was successfully deleted! "); Window.location.href= ' hanye_manages.jsp? Bigclassname= "+bbb+"; </script> ");
}
Stmt_channeldel.close ();
return;
}
Statement stmta=conn.createstatement (resultset.type_scroll_sensitive,resultset.concur_read_only);
String sqla= "SELECT * from Hl_smallclass WHERE bigname= ' industry News ' ORDER by ID ASC";
ResultSet rsa=stmta.executequery (SQLA);
while (Rsa.next ()) {

%>
<a class= ' T2 ' href= ' hanye_manages.jsp?modi= news &bigclassname=<%=rsa.getstring ("Smallname")%> ' >< %=rsa.getstring ("Smallname")%></a> |
<%
}
Rsa.close (); Close Recordset object
Stmta.close (); Close Statement Object
%>
</td>
</tr>

<tr>
&LT;TD height= "></td>"
</tr>
<tr>
&LT;TD align= "center" valign= "Top" bgcolor= "#ECF5FF" >

<form name= "Form2" action= "list.asp?action=delall&modi= News" method= "POST" >
<table width= "100%" cellpadding= "3" cellspacing= "2" bgcolor= "#FFFFFF" style= "Word-break:break-all" >
<tr class= "T2" >
&LT;TD width= "height=" align= "center" background= "Images/admin_bg_1.gif" bgcolor= "#BBDAFF" class= "STYLE1" > Id</td>

&LT;TD width= "align=" "Center" background= "Images/admin_bg_1.gif" bgcolor= "#BBDAFF" class= "STYLE1" > News category &LT;/TD >

&LT;TD width= "align=" "Center" background= "Images/admin_bg_1.gif" bgcolor= "#BBDAFF" class= "STYLE1" > News small Class </td >

&LT;TD width= "291" align= "center" background= "Images/admin_bg_1.gif" "bgcolor=" #BBDAFF "class=" STYLE1 "style=" Word-break:break-all "> News headlines </td>

&LT;TD width= "179" align= "center" background= "Images/admin_bg_1.gif" bgcolor= "#BBDAFF" class= "STYLE1" > News pictures </ Td>

&LT;TD width= "align=" "Center" background= "Images/admin_bg_1.gif" bgcolor= "#BBDAFF" class= "STYLE1" > Release time &LT;/TD >

&LT;TD width= "align=" "Center" background= "Images/admin_bg_1.gif" bgcolor= "#BBDAFF" class= "STYLE1" > Operation </td >
</tr>
<%
int pagesize=10; Number of articles displayed per page
int showpage=1; The page number displayed on the current page
int reccount=0; Total number of articles in resultset
int pagecount=0; Total pages after pagination
String sqlarticle;

String topage = request.getparameter ("page");
String bgname = new String (Request.getparameter ("Bigclassname"). GetBytes ("Iso8859_1"));
Statement stmt_article=conn.createstatement (resultset.type_scroll_sensitive,resultset.concur_read_only);
Sqlarticle= "SELECT * from Hl_news where smallname= ' +bgname+" ' ORDER by ID DESC ";
ResultSet rsarticle=stmt_article.executequery (sqlarticle);

if (Rsarticle.next ()) {
Rsarticle.last ()//The pointer flies to the last
Reccount=rsarticle.getrow ()//Remove line number from last line
Pagecount= (reccount%pagesize) ==0? ( reccount/pagesize):(reccount/pagesize) +1)//How many pages can be divided
if (topage!=null)
Showpage=integer.parseint (ToPage);
Rsarticle.absolute ((showPage-1) *pagesize+1);//Skip to page one of ShowPage
for (int i=1;i<=pagesize;i++) {
int Nid=rsarticle.getint ("ID");
String img = rsarticle.getstring ("img");
String TTT = Rsarticle.getstring ("Times");
Ttt=ttt.substring (0,10);
%>
<tr class= "STYLE1" >
&LT;TD width= "height=" align= "center" bgcolor= "#BBDAFF" ><%=NID%></td>

&LT;TD align= "center" bgcolor= "#BBDAFF" ><%=rsarticle.getstring ("Bigname")%></td>

&LT;TD align= "center" bgcolor= "#BBDAFF" ><%=rsarticle.getstring ("Smallname")%></td>

&LT;TD align= "left" bgcolor= "#BBDAFF" ><%=rsarticle.getstring ("Title")%></td>

&LT;TD align= "center" bgcolor= "#BBDAFF" ><a href= "/<%=img%>" target= "_blank" ><%=img%></a ></td>

&LT;TD align= "center" bgcolor= "#BBDAFF" ><%=ttt%></td>

&LT;TD width= "align=" center "bgcolor=" #BBDAFF "class=" STYLE1 "><a href=" hanye_edit.jsp?id=<%=nid%> &modi= News "> Modify </a>|<a href=" hanye_manages.jsp?id=<%=nid%>&op=del&bigclassname=<% =bgname%> "onclick=" return confirm (' Delete will not be restored, are you sure to delete it? ') ' > Delete </a></td>
</tr>
<%
if (! Rsarticle.next ())
Break
}
}
%>

<input name= ' allid ' type= ' hidden ' value=>

</table>
<table width= "100%" border= "0" align= "center" cellpadding= "0" cellspacing= "0" >
<tr class= "STYLE1" >
&LT;TD width= "50%" align= "left" background= "Images/admin_bg_1.gif" >
<span class= "T2" ><strong></strong>

</span>&nbsp;&nbsp;
<label>

</label>
</td>
&LT;TD width= "56%" align= "center" background= "Images/admin_bg_1.gif" >
<div align= "left" class= "T2" >
Total <%=pageCount%> page <% for (int i=1;i<=pagecount;i++) {%> <% if (i==showpage) {%><b><%=i% ></b><%}else{%>[<a href= ' hanye_manages.jsp? Bigclassname=<%=bgname%>&page=<%=i%>&modi= News ' ><%=i%></a>] <%}}%>
</div></td>
</tr>
</table>
</form>
<form name= "Form1" method= "Post" action= "hanye_manage.jsp" > <table width= "51%" border= "0" cellspacing= "0" cellpadding= "0" >

<tr class= "T4" >
Width= "34%" height= "&LT;TD" ><span class= "STYLE1" > Enquiry:</span>
<label>
<select name= "Select" >
<option value= "id" > by ID query </option>
<option value= "title" > Query by Title </option>
<option value= "Times" > Query by Time </option>
</select>
</label>
<label>
<input type= "text" name= "K" >
<input name= "Submit" type= "Submit" class= "T5" value= "submitted" >
</label> </td>
</tr>
</table>
</form>
<br></td>
</tr>
</table>


<%
Rsarticle.close ();
Stmt_article.close ();
Conn.close ();
%>
</body>

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.