主题:请教jsp高手!
我编了一个jsp的登录界面,但是总是执行else的情况,查不出原因,请高手帮忙看一看。
<%@ page language="java" contentType="text/html;charset=gb2312" import="java.sql.*" %>
<html>
<head>
<title>登录通讯录</title>
</head>
<body>
<center>
<font size="5" color=red>登录通讯录</font>
</center>
<hr>
<form method="post">
<center>
<p>用户名:<input type="text" name="Name"></p>
<p>密 码:<input type="password" name="Password"></p>
<p><input type="submit" value="确定"> <input type="reset" value="重置"></p>
</center>
</form>
</body>
</html>
<%
if(request.getParameter("Name")!=null && request.getParameter("Password")!=null)
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:txl");//txl是odbc名称
Statement smt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
String getpaperdata="SELECT * FROM login WHERE user='"+request.getParameter("Name")+"' AND pwd='"+request.getParameter("Password")+"'";
ResultSet paperrs=smt.executeQuery(getpaperdata);
if(paperrs.next())
{
response.sendRedirect("index.jsp");
}
else
response.sendRedirect("error.htm");
}
%>
<%@ page language="java" contentType="text/html;charset=gb2312" import="java.sql.*" %>
<html>
<head>
<title>登录通讯录</title>
</head>
<body>
<center>
<font size="5" color=red>登录通讯录</font>
</center>
<hr>
<form method="post">
<center>
<p>用户名:<input type="text" name="Name"></p>
<p>密 码:<input type="password" name="Password"></p>
<p><input type="submit" value="确定"> <input type="reset" value="重置"></p>
</center>
</form>
</body>
</html>
<%
if(request.getParameter("Name")!=null && request.getParameter("Password")!=null)
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:txl");//txl是odbc名称
Statement smt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
String getpaperdata="SELECT * FROM login WHERE user='"+request.getParameter("Name")+"' AND pwd='"+request.getParameter("Password")+"'";
ResultSet paperrs=smt.executeQuery(getpaperdata);
if(paperrs.next())
{
response.sendRedirect("index.jsp");
}
else
response.sendRedirect("error.htm");
}
%>