This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Multiple Login Attempts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Multiple Login Attempts" Watch "Multiple Login Attempts" New topic

Multiple Login Attempts

vjy chin
Ranch Hand

Joined: Feb 17, 2005
Posts: 279
I am developing a web app using J2EE. I was struck in disabling the user account if he enters the information incorrectly 3 times. How can we proceed with this?

I am getting the user entered info and sending it to the action class, action class gives it to the services (delegate) class, which in turn pass to DAO class. I am not passing the request method to the DAO class, so I could not maintain a session. So how will I be able to do this.

Any ideas will be greatly appreciated. Also how do we create a new session in the DAO classes.

Scott Johnson
Ranch Hand

Joined: Aug 24, 2005
Posts: 518
One way is to store a counter in the HttpSession object that records the number of failed login attempts.

I don't know what your delegate looks like, but you might have a method called something like validateUser() that returns a boolean. When that method returns false the Action class could update the counter in the Session.

Once it reaches 3, the Action class calls another method to disable the account.

Another way would be to store the counter in the database and let the delegate handle everything.
vjy chin
Ranch Hand

Joined: Feb 17, 2005
Posts: 279
Thanks Scott,

That was what I had thought and now implemented, i.e incrementing counter in action class.

But just wanted to know is there any way to get a session value in DAO class.

Thanks again.
I agree. Here's the link:
subject: Multiple Login Attempts
It's not a secret anymore!