By zieckey ( http://blog.csdn.net/zieckey) All Rights Reserved! 这次涉及到四个文件: 登录页面:login.html 登录成功欢迎页面:login_success.jsp 登录失败页面:login_failure.jsp Servlet处理文件:LoginServlet.java 其实还涉及到一个文件:web.xml,这个后面再说: 下面分别介绍这几个文件: 登录页面:login.html <!-- 该Login页面是一个简单的登录界面 --><!-- 该JSP程序是用来测试与MySQL数据库的连接, 需要一个数据库:LearnJSP,和其中一个表:userinfo 表中有两个字段分别为:UserName varchar (20) not null,UserPwd varchar (20) not null--><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 用来提取用户填入并提交的信息--> <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> <!-- javaScript 函数 validateLogin(),用来验证用户名和密码是否为空 --> <script language="javaScript"> function validateLogin() { var sUserName = document.frmLogin.txtUserName.value; var sPassword = document.frmLogin.txtPassword.value; if( sUserName=="" ) { alert("请输入用户名!"); return false; } if( sPassword==""<