通过编程和上机实验理解 JSP各个页面之间的响应和传递的过程。并且能够熟练的掌握JSP的内置对象的属性和方法,并能灵活运用。
二、实验环境:
Eclipse、Tomcat9.0
三、实验内容:(部分代码)
1.注册页面:
<body>
<h2>用户注册</h2>
<p>欢迎您注册为本网站的会员,请在下面表单填写注册信息,
要求每项必填,信息务必真实,方便我们联系您,谢谢!</p>
<h3>创建新用户</h3>
<form method="POST" action=" Accept.jsp" name="form1" onsubmit="on_submit()">
用户名:<input type="text" name="username" size="10"><br>
密码:<input type="password" name="userpassword" size="18"><br>
确认密码:<input type="password" name="reuserpassword" size="18"><br>
电子邮箱:<input name="email" maxlength=20><br>
电话:<input name="telephonenumber"/><br>
家庭住址:<input type="text" name="address" size="30"><br>
<input type="checkbox" value="agree" name="vote" />我同意<a href="agree.jsp">相关协议与政策</a>
<p align="right"><input type="submit" value="注册" ></p>
</form>
</body>
``2.获取页面:
<body>
<h2>注册成功</h2>
<p>欢迎您注册为本网站的会员,您的注册信息如下,请记住您的注册信息!</p>
<br>
<h3>用户注册信息</h3>
用户名是:<%= (request.getParameter("username"))%><br>
密码是:<%= (request.getParameter("userpassword"))%><br>
电子邮箱是:<%=request.getParameter("email")%><br>
电话号码是:<%=request.getParameter("telephonenumber")%><br>
家庭住址是:<%=request.getParameter("address") %><br>
<a href="login.jsp">返回首页</a><br>
在这``3.登录:
<body>
<h2>我的账户</h2>
<p>请登录...</p>
<h3>登录</h3>
<form method="POST" action=" loginInfo.jsp" >
用户名:<input type="text" name="username" size="10"><br>
密码:<input type="password" name="userpassword" size="18"><br>
<input type="checkbox" value="remember" name="rem" />记住用户名
<p align="right"><input type="submit" value="login" ></p>
</form>
</body>
loginInfo:
<%
String str1=request.getParameter("username");
String str2=request.getParameter("userpassword");
if(!request.getParameter("username").equals(str1)||!request.getParameter("userpassword").equals(str2))
{
response.sendRedirect("login.jsp");
}
else
{
out.print("登录成功!");
}
%>里插入代码片