我一直在深入研究如何对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
不确定简短的想法?简单地解释一下你所面临的所有问题 –