index.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录</title>
<style>
a{ font-family: 宋体;
font-size: 20px;
}
.log{font-family: 微软雅黑;
margin: 0 auto;
width: 200px;
height: 60px;
font-size: 20px;
color: white;
background-color: orange;
cursor: pointer;
border-radius: 10px 10px 10px 10px
}
</style>
<script>
var ck = document.getElementsByName("ck").checked;
function form_onclck(obj){
if(obj.userName.value == ""){
alert("请输入用户名");
return false;
}
if(obj.password.value == ""){
alert("请输入密码");
return false;
}
return true;
}
</script>
</head>
<body>
<%
Cookie[] mycks = request.getCookies();
String[] info = new String[]{"", ""};
if (mycks != null) {
for (Cookie x : mycks) {
if (x.getName().equals("mycookie")) {
info = x.getValue().split("#");
}
}
}
%>
<center>
<h1>欢迎来到商品信息管理系统</h1>
<form action="LogServlet" method="post">
<a>用户名</a><input type="txt" name="userName" id="userName" value="<%=info[0]%>"/>
<br><br>
<a>密 码</a><input type="password" name="password" id="password" value="<%=info[1]%>"/>
<br><br>
<input type="checkbox" name="ck" checked = "checked"/>记住密码
</br>
</br>
<a href="adduser.jsp">还没有账号?立即注册</a>
</br>
</br>
<input type="submit" value="登 录" class ="log" name="submit" id="submit" onclick="return form_onclck(this.form)"/>
</form>
</center>
</body>
</html>