package org.apache.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.sql.*;
import java.io.*;
public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent {
private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();
private static java.util.Vector _jspx_dependants;
private org.apache.jasper.runtime.ResourceInjector _jspx_resourceInjector;
public Object getDependants() {
return _jspx_dependants;
}
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException {
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
PageContext _jspx_page_context = null;
try {
response.setContentType("text/html;charset=UTF-8");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
_jspx_resourceInjector = (org.apache.jasper.runtime.ResourceInjector) application.getAttribute("com.sun.appserv.jsp.resource.injector");
out.write("\n");
out.write("\n");
out.write("\n");
mysql.DBManager db = null;
synchronized (_jspx_page_context) {
db = (mysql.DBManager) _jspx_page_context.getAttribute("db", PageContext.PAGE_SCOPE);
if (db == null){
db = new mysql.DBManager();
_jspx_page_context.setAttribute("db", db, PageContext.PAGE_SCOPE);
}
}
out.write('\n');
int pagesize = 5; //每页显示的数据量
StringBuffer userInfo = new StringBuffer();
StringBuffer pageInfo = new StringBuffer();
ResultSet rs = db.getResult("select * from student_info");
String paramPage = request.getParameter("page");
int currentPage = 1;
try{
currentPage = Integer.parseInt(paramPage);
}catch(Exception e){
currentPage = 1;
}
rs.last();
int totaluser = rs.getRow();
int pagecount = (int)Math.ceil((float)totaluser/(float)pagesize);
int i = 1;
rs.absolute((currentPage-1) * pagesize + 1);
while(i<=pagesize && !rs.isAfterLast()){
userInfo.append("<tr bgcolor = #ffffff>\n");
userInfo.append("<td align = center>" + ((currentPage - 1) * pagesize + i) + "</td>");
userInfo.append("<td align = center>" + rs.getString(1) + "</td>");
userInfo.append("<td align = center>" + rs.getString(2) + "</td>");
userInfo.append("<td align = center>" + rs.getString(3) + "</td>");
userInfo.append("</tr>");
if(!rs.next()){
break;
}
i++;
}
pageInfo.append("第" + currentPage + "页 共" + pagecount + "页,共" + totaluser + "个用户 ");
if(currentPage > 1){
pageInfo.append(" <a href = 'index.jsp?page=" + (currentPage-1) + "'><< 上一页</a>");
}
else{
pageInfo.append("<< 上一页");
}
if(currentPage < pagecount){
pageInfo.append(" <a href='index.jsp?page=" + (currentPage + 1) + "'>下一页>></a>");
}
else{
pageInfo.append("下一页 >>");
}
db.close();
out.write("\n");
out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n");
out.write(" \"http://www.w3.org/TR/html4/loose.dtd\">\n");
out.write("\n");
out.write("<html>\n");
out.write(" <head>\n");
out.write(" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n");
out.write(" <title>JSP Page</title>\n");
out.write(" </head>\n");
out.write(" <body>\n");
out.write(" <table width=\"80%\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\" bgcolor=\"#000000\">\n");
out.write(" <tr align=\"center\" bgcolor=\"#cccccc\">\n");
out.write(" <td width=\"12\">编号</td>\n");
out.write(" <td width=\"12\">学号</td>\n");
out.write(" <td width=\"12\">姓名</td>\n");
out.write(" <td width=\"12\">性别</td>\n");
out.write(" </tr>\n");
out.write(" ");
out.print(userInfo);
out.write("\n");
out.write(" </table>\n");
out.write(" <table width=\"80%\" border=\"0\" align=\"center\">\n");
out.write(" <tr>\n");
out.write(" <td align=\"right\">");
out.print(pageInfo);
out.write("</td>\n");
out.write(" </tr>\n");
out.write(" </table>\n");
out.write(" </body>\n");
out.write("</html>\n");
} catch (Throwable t) {
if (!(t instanceof SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
}
} finally {
_jspxFactory.releasePageContext(_jspx_page_context);
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
JSP实现分页显示数据库中的数据
共32个文件
xml:9个
jar:8个
properties:3个
需积分: 50 22 下载量 182 浏览量
2009-10-04
12:21:08
上传
评论
收藏 2.17MB RAR 举报
温馨提示
JSP实现分页显示数据库中的数据 JSP实现分页显示数据库中的数据 JSP实现分页显示数据库中的数据 JSP实现分页显示数据库中的数据
资源推荐
资源详情
资源评论
收起资源包目录
.rar (32个子文件)
分页显示
test
build.xml 3KB
dist
____.war 811KB
src
conf
MANIFEST.MF 25B
java
mysql
DBManager.java 1KB
nbproject
build-impl.xml 45KB
private
private.xml 211B
private.properties 2KB
ant-deploy.xml 4KB
project.xml 692B
genfiles.properties 464B
project.properties 2KB
web
WEB-INF
sqljdbc.jar 400KB
mssqlserver.jar 66KB
msbase.jar 280KB
web.xml 490B
msutil.jar 58KB
sun-web.xml 505B
index.jsp 3KB
build
empty
generated
src
org
apache
jsp
index_jsp.java 6KB
index_jsp.class.smap 133B
classes
org
apache
jsp
index_jsp.class 6KB
web
META-INF
MANIFEST.MF 25B
WEB-INF
sqljdbc.jar 400KB
mssqlserver.jar 66KB
msbase.jar 280KB
web.xml 490B
msutil.jar 58KB
classes
.netbeans_automatic_build 0B
mysql
DBManager.class 2KB
sun-web.xml 505B
gfv3.dpf 505B
index.jsp 3KB
共 32 条
- 1
资源评论
萌猫他爸
- 粉丝: 24
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功