我一直在深入研究如何對servlet中的登錄嘗試進行驗證。登錄嘗試Servlet - 如果用戶全部3次登錄嘗試失敗,則禁用用戶10分鐘
舉一個例子。
1)如果用戶登錄不正確的密碼//它將返回到登錄頁面
2)用戶將只有3次嘗試。
3)未能在第3次嘗試登錄後。他們將被禁賽10分鐘
的login.jsp
<form action = "loginController">
<input type="text" name="username">
<input type="text" name="password">
<input type="submit" value="Submit"/>
</form>
至於我們的servlet文件
loginController.java
我明白,我們必須分配會話的用戶名,這樣每個用戶名將有一個獨特的會話ID附加到它,但我真的不確定我們可以做到這一點。
doPost(HttpServletRequest...)
{
String name = request.getParameter("username");
String pass = request.getParameter("password");
//we will create session and append it to username
HttpSession session = request.getSession(true);
session.setAttribute("username" , name);
//what im really unsure is how we can get the sessionID to telly with the username
int countAttempt = new Integer(0);
if(countAttempt <= 3){
response.sendRedirect("login.jsp");
} else if(countAttempt == 3){
//This will ban users to log in for 10mins....
}
這是核心Java平臺我以前的模塊,有什麼地方對servlet的要求我們與控制器進行通信,並返回到JSP是相當大的挑戰中很容易實現。
任何幫助將大大appreaciated
不確定簡短的想法?簡單地解釋一下你所面臨的所有問題 –