JSP实例三、sql分页(1)
index.jsp
<%@ page language="java" import="java.sql.*" import="java.lang.*" import="java.util.*" pageEncoding="GB2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%!
int CountPage = 0;
int CurrPage = 1;
int PageSize = 5;
int CountRow = 0;
public Connection Con() {
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection Con = DriverManager.getConnection("jdbc:mysql://localhost:3306/userdb?user=root&password=zhz&useUnicode=true&characterEncoding=gb2312");
return Con;
}
catch(Exception e)
{
return null;
}
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>利用 SQL 语句实现分页</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description"
相关文档:
image.jsp用于生成数字图片
<%@ page contentType="image/jpeg;charset=gb2312" import="java.awt.*,
java.awt.image.*,java.util.*,javax.imageio.*" %>
<%!
Color getRandColor(int fc,int bc){//给定范围获得随机颜色
Random random = new Rand ......
<%--
有些朋友询问使用 JSP Smart 下载文件的时候报错, 这里给出一个测试过的不
需要使用 JSP Smart 的 JSP 页面中进行文件下载的代码(改 Servlet 或者
JavaBean 的话自己改吧), 支持中文附件名(做了转内码处理). 事实上只要向 ......
学习JSP主要学习他的9大对象(request, response, pageContext, session, application, out, config, page, exception ),这些对象都是静态对象,不用定义就可以直接使用,把他们都了解清楚并会运用,就可以在简历上添上一个熟悉技能:JSP
Jsp内置对象 功能 主要方法
out 向客户端输出数据 print() println() flush() ......