Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Login page problem

 
saurabh swaroop
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic