괜찮습니다. 이제 사용자가 로그인 한 후 세션을 만들고 로그인 시도가 실패한 횟수가 3이되면 보안 질문으로 리디렉션하고 싶습니다. 어떻게 할 수 있습니까?로그인 페이지에 대한 세션 생성 및 로그인 실패 횟수 계산
사용자 로그인 및 로그 아웃 세션을 만드는 방법은 무엇입니까? 로그인 시도 횟수를 계산하는 방법은 무엇입니까?
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/mutualfund", "root", "");
Statement stmt = con.createStatement();
String uname = request.getParameter("username");
String pass = request.getParameter("password");
String query = "SELECT * FROM `login_table` WHERE `username`=\""+uname +"\" and `password`=\""+pass+"\"";
ResultSet result = stmt.executeQuery(query);
if(result.next())
{
System.out.println("entered into if loop");
if (result.getString(1).equals(uname)
&& result.getString(2).equals(pass)) {
System.out.println("Uname and pass are correct");
if (result.getBoolean(7) == true) {
System.out.println("redirecting to admin profile");
response.sendRedirect("displayFunds.jsp");
}
else if ((result.getBoolean(7) == false)
&& (result.getInt(3)==0)) {
System.out.println("first time login for customer, redirecting to change pass");
response.sendRedirect("changePassword.jsp?name="
+ uname + "&&pass=" + pass);
}
else if ((result.getBoolean(7) == false)
&& (result.getInt(3)==1)) {
System.out.println("active customer login");
response.sendRedirect("custProfile.jsp");
}
}
else {
response.sendRedirect("loginFailed.jsp");
}
}
} catch (Exception ex) {
Logger.getLogger(Admin.class.getName()).log(Level.SEVERE, null, ex);
}
}
세션 속성에 로그인 시도 횟수를 입력해야합니다. – NINCOMPOOP
내가 말했듯이 나는 돈이별로 없거나 거의 아무것도 말할 수 없다. –
유용한 추가 정보 : [세션 추적] (http://www.java-programming.info/tutorial/pdf/csajsp2/08-Session-Tracking.pdf) – informatik01