查看注册信息application

保存用户注册信息,使用application

注册界面:

<%@ 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>注册</title>
</head>
<body>

<form action="appzhuce2.jsp" method="post">
<table width="300">
<tr>
<td width="200">请输入昵称:</td>
<td><input type="text" name="name"/></td>
</tr>
<tr>
<td width="200">请输入密码:</td>
<td><input type="password" name="password1"/></td>
</tr>
<tr>
<td width="200">请确认密码:</td>
<td><input type="password" name="password2"/></td>
</tr>
<tr>
<td width="200">请输入邮箱:</td>
<td><input type="text" name="email"/></td>
</tr>

<tr>
<td width="200">请输入手机号码:</td>
<td><input type="text" name="phonenum"/></td>
</tr>

<tr>
<td width="150"><input type="submit" value="提交"/></td>
<td><input type="reset" value="重置"/></td>
</tr>


</table>



</form>






</body>
</html>

判断,接收,处理界面:

<%@ 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>判断注册信息</title>
</head>
<body>
<%
String name=new String(request.getParameter("name").getBytes("ISO-8859-1"),"UTF-8");
String pw1=request.getParameter("password1");
String pw2=request.getParameter("password2");
String mail=request.getParameter("email");
String phone=request.getParameter("phonenum");

if(name==""||pw1==""||pw2==""||mail==""||phone=="")
{
    out.print("注册信息不能为空,5秒后返回注册页面<br>");
    response.setHeader("refresh", "5;appzhuce.jsp");
    }
else if(!pw1.equals(pw2))
{
    out.print("您两次输入的密码不一致,请重新输入");
    response.setHeader("refresh", "5;appzhuce.jsp");
    
    }

else
{
    out.print("注册成功");
    String s="姓名:"+name+"<br>密码:"+pw1+"<br>邮箱:"+mail+"<br>手机号:"+phone+"<br>";
    String info=(String)application.getAttribute("xinxi");
    if(info==null)
    {
        application.setAttribute("xinxi", s);
        
        }
    else
    {
        info+=s;
        
        application.setAttribute("xinxi",info);


    }

}

%>

<form action="appzhuce3.jsp">

<table>
<tr><td>查看注册信息</td></tr>
<tr><td><input type="submit" value="查看"/></td></tr>


</table>


</form>




</body>
</html>

查看注册信息:

<%@ 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 str=(String)application.getAttribute("xinxi");
out.print(str);
%>





</body>
</html>

运行结果图片:

posted @ 2016-07-01 08:56  鱼在我这里  阅读(252)  评论(0编辑  收藏  举报