<%@ 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> <script type="text/javascript"> function check() { var uid =document.getElementById("userid"); if(uid.value =="") { alert("代码不能为空"); return false; } if(uform.password.value=="") { alert("密码不能为空"); return false; } return true; } </script> </head> <body> <form id="uform" action ="yanzheng.jsp" method="post" onSubmit="return check();"> 用户:<input id="userid" type="text" name="userid" width=30/> 密码:<input id="passeord" type="password" name="password" width=30/> <input type="submit" value="登录" /> <a href ="zhuce.jsp">注册新用户</a> </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 strUserid =request.getParameter("userid"); String strPW =request.getParameter("password"); if(strUserid == null || strUserid.trim().length() == 0) { response.sendRedirect("message.jsp?msgid=1"); } else if(strPW == null || strPW.trim().length() == 0) { response.sendRedirect("message.jsp?msgid=2"); } else {//查找用户信息 Object obj=application.getAttribute(strUserid); if(obj!=null){ String strUser=obj.toString(); String[] user= strUser.split("#"); String strUID =user[0]; String strUsername =user[1]; String strP =user[2]; if(strPW.equals(strP)) { out.print("欢迎"+strUsername+"登陆"); //跳转到系统页面 session.setAttribute("login",strUsername); } else { response.sendRedirect("message.jsp?msgid=3"); } } else { response.sendRedirect("message.jsp?msgid=4"); } } %><br><br> <a href="liuyan.jsp">留言</a> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="java.util.*" %> <!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 strMsgId =request.getParameter("msgid"); if(strMsgId == null || strMsgId.trim().length()==0) { out.print("信息错误"); } else { int iMsgid = Integer.parseInt(strMsgId); switch (iMsgid) { case 1: out.print("账号输入错误"); break; case 2: out.print("密码输入错误"); break; case 3: out.print("密码错误"); break; case 4: out.print("用户不存在"); break; case 5: out.print("请正确输入用户名"); break; case 6: out.print("提交成功"); break; case 7: out.print("用户代码已存在"); break; case 8: out.print("用户未登录"); break; default: out.print("无法识别信息"); break; } } response.setHeader("refresh","3;URL=Login.jsp"); %> </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 strUserid =request.getParameter("userid"); String strUsername =request.getParameter("username"); String strPW =request.getParameter("password"); if(strUserid == null || strUserid.trim().length() == 0) { response.sendRedirect("message.jsp?msgid=1"); } else if(strUsername == null || strUsername.trim().length() == 0) { response.sendRedirect("message.jsp?msgid=5"); }else if(strPW == null || strPW.trim().length() == 0) { response.sendRedirect("message.jsp?msgid=2"); } else {//查找用户信息 Object obj=application.getAttribute(strUserid); if(obj!=null){ response.sendRedirect("message.jsp?msgid=7"); } else{ strUsername=new String(strUsername.getBytes("ISO-8859-1"),"UTF-8"); String strUser=strUserid+"#"+strUsername+"#"+strPW; application.setAttribute(strUserid,strUser); response.sendRedirect("message.jsp?msgid=6"); } } %> </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> <script type="text/javascript"> function check() { var uform =document.getElementById("userid"); if(uform.userid.value =="") { alert("代码不能为空"); return false; } if(uform.username.value =="") { alert("名称不能为空"); return false; } if(uform.password.value=="") { alert("密码不能为空"); return false; } if(uform.password.value!=uform.queren.value) { alert("密码不一致"); return false; } return true; } </script>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="java.util.*" %> <%@page import="java.text.*" %> <!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> <% String userName =""; //检查登录状态 Object o =session.getAttribute("login"); if(o == null) { response.sendRedirect("message.jsp?msgid=8"); } else { userName = o.toString(); } String liuyan=request.getParameter("liuyan"); if(liuyan != null && liuyan.equals("")) { String strLiuyan=new String(liuyan.getBytes("ISO-8859-1"),"UTF-8"); //附加时间信息 Date dt = new Date(); //格式化时间 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); strLiuyan += " "+sdf.format(dt)+"留言人:"+userName; Object obj = application.getAttribute("liuyan"); ArrayList<String> a; if(obj==null) { a = new ArrayList<String>(); } else { a = (ArrayList<String>)obj; } a.add(strLiuyan); application.setAttribute("liuyan", a); } else { } %> </head> <body> <form > 最新留言:<br> <% int i =1; Object obj = application.getAttribute("liuyan"); if(obj !=null) { ArrayList<String> a = (ArrayList<String>)obj; for(int m = a.size()-1; m>=0;m-- ) { out.print(i+". "+a.get(m)+"<br>"); i++; } } %> 请留言<br> <textarea rows="10" cols="50" name="liuyan"></textarea> <br> <input type=submit value="提交"> </form> </body> </html>
</script>
</head>
<body>
<form id="uform" action="saveUser.jsp" method="post" onSubmit="return check();">
用户代码:<input id="userid" type="text" name="userid" width=30/><br><br>
用户名称:<input id="username" type="text" name="username" width=30/><br><br>
登录密码<input id="password" type="password" name="password" width=30/><br><br>
确认密码:<input id="queren" type="password" name="queren" width=30/><br><br>
<input type="submit" value="提交"/>
</body>
</html>