I created one web application so i want to store my past logged user name list for comparing new users which are going to login. so how i do that by using ServletContext ? or is there any other way?
Asked
Active
Viewed 872 times
4
-
clarify. "compare new existing logged users" doesn't make much sense to me. – Bozho Sep 23 '10 at 10:29
-
It's never wise to store user passwords anywhere. – Buhake Sindi Sep 23 '10 at 10:46
-
can u please check my question again? – vinod Sep 23 '10 at 10:46
-
Are you comparing new users to ensure usernames are unique? or you want to check that the same user does not login again (when he is already logged in)? How does the password matter in all this? – JoseK Sep 23 '10 at 10:58
-
JoseK, sorry for mentioning password in my question and yes same user does not login again that's correct understanding!! – vinod Sep 23 '10 at 11:03
-
@vinod: so your question is "How to prevent duplicate login using the same username and password". Add that bit so it makes it easier for others – JoseK Sep 23 '10 at 11:16
-
yes, ok thanks for this discussion – vinod Sep 23 '10 at 11:24
1 Answers
2
In JSF, application scoped managed beans are stored in the servletcontext. So, you could basically just create and declare an application scoped managed bean and put the list in there.
However, there are probably better ways for the particular functional requirement which is yet unclear in the question. At least, implementing a HttpSessionListener
or HttpSessionBindingListener
is probably a better idea since logins are usually coupled to the HttpSession
.
Here are several examples:
-
2@vinod: on this site, the right way to say thanks means upvote or accept the answer. – JoseK Sep 23 '10 at 11:42
-
@balusC i tried using HttpSessionBindingListener but i am not able to do, can u send me the some example which can be helpful for solving this problem? – vinod Sep 24 '10 at 14:21
-
-
The examples are available in the links in the answer. In the future, you need to elaborate the "i am not able to do" in more detail. What are the functional requirements? What code do you have as far? What exactly happens? What exactly happens not? As far now it much sounds like that you couldn't even write a single line of code or couldn't get it to compile. My direct answer would then be: learn Java first. – BalusC Sep 24 '10 at 14:26
-
@balusC sry for asking simple question. actually i am new in the web development word so i am trying to learn as much as possible with the help of internet and from the guys like u. and i am trying to improve my knowledge also in java. and i accept your direction sir Thanks!!! – vinod Sep 24 '10 at 14:40