Efficient and simple JSP pages

Source: Internet
Author: User
Tags sql string
JS <%@ page import= "java.sql.*,java.io.*,java.util.*"%>
<%@ page language= "java" pageencoding= "Big5"%>
<%! String au_id,au_lname,au_fname,phone,address,city,state;%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<link rel= "stylesheet" href= "Style.css" >
<body bgcolor= "#FFFFFF" > <table width= "760" border= "0" cellspacing= "0" cellpadding= "0" align= "center" >
<table width= "750" border= "0" cellspacing= "2" cellpadding= "2" align= "Center" >
&LT;TR align= "center" >
<td> </td>
<table width= "740" border= "0" cellspacing= "1" cellpadding= "1" align= "Center" >
&LT;TR align= "center" bgcolor= "#CCCCCC" >
<td><b> title </b></td>
<td><b> author </b></td>
<td><b> Types </b></td>
<td><b> Click </b></td>
<td><b> Join Time </b></td>
int i;
int ipage=5; Pages
int allpage; Page numbers
int pages; The number of pages accepted
int cpage=1; When you are in front of
int spage; Start Page
int allcol=0;
Vector v=null;//Data Library connection sounds
Connection Conn=null;
Java.lang.String Sql,pagesql;
Java.sql.ResultSet rs,pagers;
Statement Statement=null;
String kmsdb= "Jdbc:microsoft:sqlserver://;databasename=dbname";
Class.forName ("Com.microsoft.jdbc.sqlserver.SQLServerDriver");
conn = Drivermanager.getconnection (Kmsdb, "User", "pwd");

Pagesql = "Select COUNT (*) from Authors"; Take the total number of articles
statement = Conn.createstatement ();
pagers = Statement.executequery (pagesql);
while (Pagers.next ())
Allcol = Pagers.getint (1);
System.out.println (Allcol); }

Get the number of pages
Allpage = (int) Math.ceil (allcol + ipage-1)/ipage);
Whether the number of pages is empty
if (Request.getparameter ("pages") ==null) {
} else {
pages = new Integer (Request.getparameter ("pages")). Intvalue ();
To judge the front page
if (pages > Allpage | | pages = 0)
{cpage = 1;}
cpage = pages;
The starting page is judged
sql = ' Select top ' +ipage+ ' au_id,au_lname,au_fname,address,phone from authors where au_id ' not in ' (select Top + (cpage-1) * Ipage+ "au_id from authors order BY au_id Desc", ORDER BY au_id DESC ";
rs = statement.executequery (SQL);
while (Rs.next ())
Au_id=rs.getstring ("au_id");
Au_lname=rs.getstring ("au_lname");
Au_fname=rs.getstring ("au_fname");
Phone=rs.getstring ("Phone");
Address=rs.getstring ("Address");%>
&LT;TD width= "><%= au_id%></a></td>"
&LT;TD width= "><%= au_lname%></a></td>"
&LT;TD width= "><%= au_fname%></a></td>"
&LT;TD width= "><%=" Phone%></a></td>
&LT;TD width= "><%=" Address%></a></td>
<tr bgcolor= "#CCCCCC" >
&LT;TD colspan= "5" align= "right" valign= "middle" > A total of <%= allcol%> a total <%= allpage%> page <% if (cpage>1) {%><a href= "fy.jsp?pages=<%= cpage-1%>" ></a><%} if (cpage<allpage) {%><a href=" fy.jsp?pages=<%= cpage+1% > "></a><%}% >/<% for (i=1;i<=allpage;i++) {if (I!= pages) {%><a href= "fy.jsp?pages=<%= i%>" ><%= i%&gt ;</a> <%}}%></td>

Related Article

Alibaba Cloud 10 Year Anniversary

With You, We are Shaping a Digital World, 2009-2019

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.