Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Log in problems using Jsp,Srvlet and Beans

 
Max Nordio
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm doing a page with Jsp,Servlet and Bean to allow entering in my site only to registered users. I decided to use session and to give a session to every new registered user logged in my site. To prevent the collision of two people with the same user at the same time I used a field called P in my user database; the P record associates to the user logged is set to 1. Everytime everybody tries to use the same user, a check method read a P=1 and stop him. When a user logouts the his P is reset; also when the browser is closed (without logging out) I used a JavaScript to grab the event and to reset the proper P. But when the session is invalidated due to time out how can I grab the user name for that session and put his P to 0? I decided to use a timer so that after 5 hours the P is however reset and the user is logged out but I don't think is good; in fact for example if the client crashes he can't use the same user for at least 5 hours, because he has to wait for the P to go to 0!
Thank you,
MAX.
 
Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You coul�d use the HttpSessionBindingListener or HttpSessionListener interfaces
take a look at: http://java.sun.com/j2ee/tutorial/api/index.html
 
Max Nordio
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Marcos Maia:
You coul�d use the HttpSessionBindingListener or HttpSessionListener interfaces
take a look at: http://java.sun.com/j2ee/tutorial/api/index.html


Thank you Marcos,
I tried to use it but when you receive the event of closing session, every single attribute stored in the session is lost and you can't get back the user name whose P must be reset.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic