| Author |
Login page problem
|
saurabh swaroop
Greenhorn
Joined: Jul 17, 2008
Posts: 7
|
|
I have to block a user in a login page.
suppose a user logins with a login id and enters wrong password 2 times.
at the third attempt he changes the userid.now again the user should be allowed three chances before it is blocked.
what i am doing is.
1>i have made login.jsp
<body>
<center>
<form method="post" action="Ser2">
USER ID:<input type="text" name="param1">
PASSWORD: <input type="password" name="param2">
<input type="submit" value="enter">
</form>
</center>
</body>
2>it goes to a servlet
String userid=request.getParameter("param1");
String pass=request.getParameter("param2");
To2 t=new To2();
Dao d=new Dao();
boolean x=d.check_user(userid);
usertrack c=usertrack.getusertrack();
String s=c.getUser();
if(x==true)
{
HttpSession session=request.getSession();
session.setAttribute("user", userid);
RequestDispatcher rd=request.getRequestDispatcher("Ser3");
rd.forward(request, response);
}
else{
RequestDispatcher rd=request.getRequestDispatcher("login_fail.jsp");
rd.forward(request, response);
}
}
3>what should i do now.i cannot guess
|
 |
Balu Sadhasivam
Ranch Hand
Joined: Jan 01, 2009
Posts: 874
|
|
the question is to vague to answer. Please explain the code better.
I have to block a user in a login page.
suppose a user logins with a login id and enters wrong password 2 times.
at the third attempt he changes the userid.now again the user should be allowed three chances before it is blocked.
Ok for the problem when the user uses different user id in the third attempt , he should be given 3 three chances.
- Each time when the form is submitted , you store the user id in the session attribute , Now check
HTH
|
 |
saurabh swaroop
Greenhorn
Joined: Jul 17, 2008
Posts: 7
|
|
how to check in the begining that the userid is same or not .
suppose a user enters the userid for the first time.
now there is no attribute et so if we perform session.getattribute() then it will give null pointer exception
|
 |
Balu Sadhasivam
Ranch Hand
Joined: Jan 01, 2009
Posts: 874
|
|
saurabh swaroop wrote:how to check in the begining that the userid is same or not .
suppose a user enters the userid for the first time.
now there is no attribute et so if we perform session.getattribute() then it will give null pointer exception
It would return null, not null pointer exception unless you use it without checking for null.
check like
Again the read the logic which i sent before. dine get that ?
|
 |
 |
|
|
subject: Login page problem
|
|
|