一、实验目的
通过编程和上机实验理解 JSP各个页面之间的响应和传递的过程。并且能够熟练的掌握JSP的内置对象的属性和方法,并能灵活运用。
二、实验要求
1. 基础练习:内置对象常用方法的使用。
2. 编写获取表单数据。
3. 按照下列要求实现简单注册、登录程序。
三、实验代码及运行页面
<%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2020/10/13
Time: 20:20
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>我的账户页面</title>
<style>
.w{
/*text-align: center;*/
background-color: #ccc;
width: 450px;
height: 225px;
margin: 50px auto;
}
.t{
text-align: left;
padding: 15px;
}
label{
display: inline-block;
text-align: right;
width: 65px;
padding: 10px 15px;
}
input{
display: inline-block;
text-align: left;
margin: 10px;
}
.submit{
display: inline-block;
margin: 0px 20px;
}
.b div{
margin: 0 80px;
}
.a{
display: inline-block;
}
.check{
color:#A7482A ;
}
</style>
</head>
<body>
<div class="w">
<div class="t"><strong>请登录...</strong></div>
<div class="b">
<div>
<label>用户名:</label>
<span><input type="text"></span>
</div>
<div>
<label >密码:</label>
<span><input type="password"></span>
</div>
<div>
<span class="check"><input type="checkbox" >记住用户名</span>
</div>
<div>
<span>
<a href="login.jsp"><input type="submit" value="注册"></a>
<input type="submit" value="登录" class="submit">
</span>
</div>
</div>
</div>
</body>
</html>
<%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2020/10/13
Time: 20:20
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>用户注册页面</title>
<style>
.w{
/*text-align: center;*/
background-color: #ccc;
width: 580px;
height: 430px;
margin: 50px auto;
}
.t{
text-align: left;
margin: 10px;
}
label{
display: inline-block;
text-align: right;
width: 155px;
}
input{
display: inline-block;
text-align: left;
margin: 10px;
}
.submit{
display: inline-block;
margin: 10px 290px;
}
.agree{
margin: 0 165px;
}
.agree span{
color:#A94424;
}
a{
color:#F9991F;
}
</style>
</head>
<body>
<div class="w">
<form action="login_success.jsp">
<div class="t">
<strong>欢迎您注册为本网站的会员,请在下面表单填写注册信息,要求每项必填,信息务必真实,方便我们联系您,谢谢!</strong>
</div>
<div>
<div>
<label>用户名:</label>
<span><input type="text" name="userName"></span>
</div>
<div>
<label>学号:</label>
<span><input type="text" name="id"></span>
</div>
<div>
<label >密码:</label>
<span><input type="password" name="pwd"></span>
</div>
<div>
<label>密码确认:</label>
<span><input type="password"></span>
</div>
<div>
<label>电子邮件:</label>
<span><input type="text" name="email"></span>
</div>
<div>
<label>电话:</label>
<span><input type="text" name="modile"></span>
</div>
<div>
<label>地址:</label>
<span><input type="text" name="address"></span>
</div>
<div class="agree">
<span class="check"><input type="checkbox">我同意<a href="javascript:;">相关协议和政策</a></span>
</div>
<div>
<span><input type="submit" value="注册" class="submit"></span>
</div>
</div>
</form>
</div>
</body>
</html>
<%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2020/10/13
Time: 20:20
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>注册成功页面</title>
<style>
a{
color:#F99E30
}
.w{
width: 600px;
height: 250px;
background-color: #ccc;
margin: 30px auto;
}
.t{
padding: 15px;
}
.sub{
padding: 15px;
}
</style>
</head>
<body>
<%
String name=request.getParameter("userName");
String id=request.getParameter("id");
String pwd=request.getParameter("pwd");
String email=request.getParameter("email");
String modile=request.getParameter("modile");
String address=request.getParameter("address");
%>
<div class="w">
<div class="t"><strong>欢迎您注册为本网站的会员,您的注册信息如下,请记住您的注册信息!</strong></div>
<div class="sub">用户注册信息:</div>
<b>用户名:</b><%=name%><br>
<b>学号:</b><%=id%><br>
<b>密码:</b><%=pwd%><br>
<b>电子邮箱:</b><%=email%><br>
<b>电话:</b><%=modile%><br>
<b>地址:</b><%=address%><br>
<a href="index.jsp">返回首页</a>
</div>
</body>
</html>