这次涉及到四个文件:
登录页面:login.html
登录成功欢迎页面:login_success.jsp
登录失败页面:login_failure.jsp
Servlet处理文件:LoginServlet.java
其实还涉及到一个文件:web.xml,这个后面再说:
下面分别介绍这几个文件:
登录页面:login.html
<html>
<head>
<title>登录</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Language" content="ch-cn">
</head>
<body>
<form method="post" name="frmLogin" action="LoginServlet">
<h1 align="center">用户登录</h1><br>
<div align="center">用户名:
<input type="text" name="txtUserName" value="Your name"
size="20" maxlength="20"
onfocus="if(this.value=='Your name')this.value='';"><br>密码:
<input type="password" name="txtPassword" value="Your password"
size="20" maxlength="20"
onfocus="if(this.value=='Your password')this.value='';"><br>
<input type="submit" name="Submit" value="提交" onClick="validateLogin();" >
<input type="reset" name="Reset" value="重置"><br>
</div>
</form>
<script language="javaScript">