0
即使輸入正確的用戶名和密碼組合,登錄頁面也會顯示一條錯誤消息,指示登錄失敗。這個問題的原因是什麼?登錄頁面輸入正確的用戶名和密碼
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:mydsn","sa","[email protected]");
String sql = "select customer_id, fname, lname, email_id, phone_number from customer_details where user_name=? and password=?";
PreparedStatement stmt;
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
session.setAttribute("customerId", rs.getString(1));
session.setAttribute("userName", userName);
session.setAttribute("fName", rs.getString(2));
session.setAttribute("lName", rs.getString(3));
session.setAttribute("emailId", rs.getString(4));
session.setAttribute("phoneNumber", rs.getString(5));
conn.close();
%>
<jsp:forward page="welcome.jsp" />
<%} else {%>
Sorry! You have entered an invalid username or password. Please try again.
<%}
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
有了這個代碼,這是不可能的,你得到一個錯誤頁面「對不起!您輸入了無效的用戶名或密碼。請再試一次「,它會引發HTTP 500內部服務器錯誤。 – BalusC 2011-03-01 12:32:38