151127

<%@ 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>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">

</script>
</head>
<body>
<form action="saveUser.jsp">
用户代码:<input type="text" name="userid" width=30/><br><br>
用户名称:<input type="text" name="username" width=30/><br><br>
登录密码<input type="password" name="password" width=30/><br><br>
确认密码:<input type="password" name="queren" width=30/><br><br>
<input type="submit" value="提交"/>
</body>
</html>

  

原文地址:https://www.cnblogs.com/zhuxiaolin/p/5001808.html