首页 新闻 会员 周边

制作一个Servlet or JSP 用来验证用户名和密码是否与服务器数据匹配!

0
悬赏园豆:10 [待解决问题]

制作一个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">

<head

>
<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">&nbsp;</h2>
</div>
</div>
   <div style="clear: both;">&nbsp;</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;
}

 

求高手指点

问题补充: There should be at least three valid subscribers. The necessary subscriber details can be hard-coded into the servlet. 不要配置服务器 直接把客户信息hard-coded 到servlet就可以了
lazyboy2046的主页 lazyboy2046 | 初学一级 | 园豆:190
提问于:2010-10-13 17:04
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册