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?
A:
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:
BalusC
2010-09-23 11:21:48
@balusC thanks For giving me this answer!!!
vinod
2010-09-23 11:30:13
@vinod: on this site, the right way to say thanks means upvote or accept the answer.
JoseK
2010-09-23 11:42:47
@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
2010-09-24 14:21:09
or anyone can me give the different approach?
vinod
2010-09-24 14:22:09
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
2010-09-24 14:26:47
@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
2010-09-24 14:40:42
I have done it thanks for all your supports!!!
vinod
2010-09-25 09:39:53