制作一个Servlet or JSP 用来验证用户名和密码是否与服务器数据匹配!如果成功跳转到index.HTML;反之跳转到logfail页面。 我已经写好了这三个页面, 但是不知道怎么用Servlet or JSP验证 并把他们联系起来!
这个我的login页面:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
>
<title>Customer Login</title>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="validateform.js">
</script>
</head>
<body>
<form action="customerLogin" method="post" onsubmit="return validate(this)">
<div id="logo">
<h1><img src="images/LOGO.jpg" alt="" width="322" height="83" /></h1>
</div>
<hr />
<div id="header">
<div id="menu">
<ul>
<li></li>
<li class="current_page_item"></li>
<li></li>
<li></li>
</ul>
</div>
</div>
<div id="page">
<div id="content">
<div class="post">
<table width="613" height="179">
<tr>
<td><label for="loginid">Login Name:</label></td>
<td><input type="text" id="loginid" /></td>
</tr>
<tr>
<td><label for="pword">Password:</label></td>
<td><input type="password" id="pword" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Login" />
<input type="reset" value="Clear form" /></td>
</tr>
</table>
<h2 class="title"> </h2>
</div>
</div>
<div style="clear: both;"> </div>
</div>
<div id="footer">
<p>Copyright (c) 2010 PENG CHI. Design by PENG CHI.</p>
</div>
</body>
</html>
这个是validateform.js
// validateform.js
function validate(loginForm)
{
var booValid = true;
var strErrorMessage = "";
if(loginForm.loginid.value == "")
{
strErrorMessage += "user name field cannot be empty\n";
booValid=false;
}
if(loginForm.pword.value=="")
{
strErrorMessage += "password field cannot be empty";
booValid=false;
}
if(!booValid)
{
alert(strErrorMessage);
}
return booValid;
}
求高手指点