[TOC]
# 用户注册实例
**代码片段:**
reg.jsp
~~~
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="regService.jsp" method="post">
用户名:<input type="text" name="username" value=""/><br/>
密码:<input type="password" name="password" value=""/><br/>
<input type="submit" value="注册" />
</form>
</body>
</html>
~~~
regService.jsp
~~~
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String username = request.getParameter("username");
String password = request.getParameter("password");
boolean usernameCheck = null != username && username.trim().length() > 6;
boolean passwordCheck = null != password && password.trim().length() > 6;
if (usernameCheck && passwordCheck) {
// 往数据库插入数据
%>
<jsp:forward page="regSuccess.jsp"></jsp:forward>
<%
} else {
%>
<jsp:forward page="regError.jsp"></jsp:forward>
<%
}
%>
</body>
</html>
~~~
regSuccess.jsp
~~~
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>恭喜你,注册成功!</h1>
<!-- 把所有的注册用户信息全部都显示出来 -->
</body>
</html>
~~~
regError.jsp
~~~
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>用户名或者密码不符合要求,<a href="reg.jsp">点击重新注册</a></h1>
</body>
</html>
~~~
- 前言
- 计算机概论
- 数据库
- 数据库介绍
- MySQL的安装
- SQL
- 表基本操作
- 修改数据语句
- 数据检索操作
- 多表数据操作
- 表结构设计
- 综合应用
- JAVA
- JAVA 介绍
- JAVA 运行原理
- JDK 配置
- 类和对象
- 数据类型
- 变量
- 直接量
- 运算符
- 流程控制
- 数组结构
- 面向对象
- 隐藏和封装
- 深入构造器
- 类的继承
- 多态
- 包装类
- final 修饰符
- 抽象类
- 接口
- 集合框架
- 常用类学习
- 异常处理
- 设计模式-单例模式
- JDBC
- JSP&Servlet
- Web应用
- Tomcat
- JSP
- Scriptlet
- Page 指令
- 包含指令
- 跳转指令
- 用户注册实例
- JSP练习
- 内置对象
- Servlet
- 过滤器
- Web分层思想
- EL表达式
- JSTL
- 分页实现
- AJAX&JSON
- 开发步骤
- 路径问题
- Log4j
- Java 高级
- 文件操作
- 泛型
- 类加载机制和反射
- 注解 Annotation
- 教学管理
- 学员名录
- 缺勤记录
