jsp内置对象作业

  1. 基础练习:内置对象常用方法的使用。
  2. 编写获取表单数据。
  3. 按照下列要求实现简单注册、登录程序。
//用户注册页面
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>用户注册</title>
<p align="left"><font size="+3">用户注册</font></p>
<p align="left">欢迎您注册为本网站的会员,请在下面表单填写注册信息,要求每项必填,信息务必真实,方便我们联系您,谢谢!</p>
<style type="text/css">
.mainBox {
border: 1px dashed #0099CC;
margin: 3px;
padding: 0px;
float: left;
height: 500px;
width:400px;
position: absolute;
top:50%;
left:50%;
position:absolute;
margin-top:-220px;
margin-left:-220px;
}
.mainBox h3 {
float: left;
height: 20px;
width: 179px;
color: #FFFFFF;
padding: 6px 3px 3px 10px;
background-color: #0099CC;
font-size: 16px;
}
</style>
</head>
<body>
<form action="zhucechenggong.jsp" method="post">
<div class="mainBox">
<h3>创建新账户</h3>
<br>
<br>
<br>
<p align="center">用户名:
<input type="text" name="username"/>
<br>
<p align="center">密码:
<input type="password" name="password"/>
<br>
<p align="center">密码确认:
<input type="password" name="passwordcheck"/>
<br>
<p align="center">电子邮件:
<input type="text" name="email"/>
<br>
<p align="center">电话:
<input type="text" name="tele"/>
<br>
<p align="center">地址:
<input type="text" name="address"/>
<center>
<form>
<input type="checkbox" value="agree" name="shifoutongyi"/>
我同意 <p><a target="framename" href="https://zhidao.baidu.com/question/2117971720617361627.html">相关协议和政策</a></p>

<input type="submit" value="注册" align="left"/>
<%
String[] password2 = request.getParameterValues("password");
String[] passwordcheck = request.getParameterValues("passwordcheck");
if (passwordcheck != password2) {
request.getRequestDispatcher("fail1.jsp").forward(request, response);
}
%>
</form>
</p>
</center>
</div>
</form>
</body>
</html>
//注册成功页面
<%@ page contentType="text/html; charset=GBK" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>注册成功</title>
<p align="left"><font size="+3">注册成功</font></p>
<p align="left">欢迎您注册为本网站的会员,您的注册信息如下,请记住您的注册信息!</p>
<style type="text/css">
.mainBox {
border: 1px dashed #0099CC;
margin: 3px;
padding: 0px;
float: left;
height: 500px;
width:400px;
position: absolute;
top:50%;
left:50%;
position:absolute;
margin-top:-220px;
margin-left:-220px;
}
.mainBox h3 {
float: left;
height: 20px;
width: 179px;
color: #FFFFFF;
padding: 6px 3px 3px 10px;
background-color: #0099CC;
font-size: 16px;
}
</style>
</head>
<body>
<%request.setCharacterEncoding("GBK");%>
<form action="yonghuzhuce.jsp" method="post">
<%
String username = request.getParameter("username");
session.setAttribute("username",username);
String password = request.getParameter("password");
session.setAttribute("password",password);
String email = request.getParameter("email");
session.setAttribute("email",email);
String tele = request.getParameter("tele");
session.setAttribute("tele",tele);
String address = request.getParameter("address");
session.setAttribute("address",address);
%>
<div class="mainBox">
<h3>用户注册信息</h3>
<br>
<br>
<br>
<p align="left">&nbsp;&nbsp;用户名:
<%=username%><br>
<p align="left">&nbsp;&nbsp;密码:
<%=password%><br>
<p align="left">&nbsp;&nbsp;电子邮件:
<%=email%><br>
<p align="left">&nbsp;&nbsp;电话:
<%=tele%><br>
<p align="left">&nbsp;&nbsp;地址:
<%=address%><br>
<br>
<p align="center">
<a href="yonghuzhuce.jsp" target="fanhui">返回首页</a>
</p>
</div>
</form>
</body>
</html>
//我的账户页面
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>我的账户</title>
<p align="left"><font size="+3">我的账户</font></p>
<p align="left">请登录...</p>
<style type="text/css">
.mainBox {
border: 1px dashed #0099CC;
margin: 3px;
padding: 0px;
float: left;
height: 500px;
width:400px;
position: absolute;
top:50%;
left:50%;
position:absolute;
margin-top:-220px;
margin-left:-220px;
}
.mainBox h3 {
float: left;
height: 20px;
width: 179px;
color: #FFFFFF;
padding: 6px 3px 3px 10px;
background-color: #0099CC;
font-size: 16px;
}
</style>
<%
Cookie[] cookies = request.getCookies();
Cookie remember = null;
if (cookies != null && cookies.length > 0) {
for (Cookie c : cookies) {
if (c.getName().equals("remember")) {
remember = c;
}
}
}
%>
</head>
<body>
<div class="mainBox">
<h3>登录</h3>
<br>
<br>
<br>
<p align="center">用户名:
<input type="text" name="usernamelogin"/>
<%
String[] usernamelogin = request.getParameterValues("usernamelogin");
String[] username = request.getParameterValues("username");
if (usernamelogin != username) {
request.getRequestDispatcher("fail2.jsp").forward(request, response);
}
%>
<br>
<p align="center">密码:
<input type="password" name="passwordlogin"/>
<%
String[] passwordlogin = request.getParameterValues("passwordlogin");
String[] password = request.getParameterValues("password");
if (passwordlogin != password) {
request.getRequestDispatcher("fail3.jsp").forward(request, response);
}
%>
<br>
<br>
<input type="checkbox" value="remember" name="remember"/>记住用户名
<%=remember==null?"":"checked" %>
<br>
<br>
<input type="submit" value="login" align="right"/>
<br>
</div>
</body>
</html>
//fail1页面
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>密码错误</title>
</head>
<body>
<p align="left">两次密码输入不一致,请重新输入!</p>
</body>
</html>
//fail2页面
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>用户名错误</title>
</head>
<body>
<p align="left">用户名输入错误,请重新输入!</p>
</body>
</html>
//fail3页面
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>密码错误</title>
</head>
<body>
<p align="left">密码输入错误,请重新输入!</p>
</body>
</html>
//framename.jsp
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
</body>
</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值