?
Solved

URGENT: Sessions in JSP

Posted on 2003-03-28
4
Medium Priority
?
237 Views
Last Modified: 2010-04-01
Hi,
   I'm a brazilian man.
   Doubt in JSP:
   Suppose that I have a database with many users registereds...
   How I do for know if a user (registered and logged in yet) is online in the moment that other user search for someone in my database?
   Update a field (as "isOnline=yes") in database, after login, is a solution, but how to update the field (for "isOnline=no", by example) when the user session to expires?
   I hope you help me.
   Sorry my bad english!!!
I'm waiting...
0
Comment
Question by:marciodorimar2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 14

Accepted Solution

by:
kennethxu earned 152 total points
ID: 8228490
You are mostly correct. but I think you should use a counter instead of yes/no. because one user can have multiple session. and you also need to handle user login into same session multiple times.

Another implmentation will be use session listener to track sessions. run a timer to build/update active user table from data in active sessions
0
 
LVL 4

Assisted Solution

by:Binary1
Binary1 earned 148 total points
ID: 8240623
It is difficult to tell from a web session if someone is still active or not. This presents a lot of problems with this type of thing.

You can track within the database the last time the user interacted with the system. After a certain, predefined period the user would be considered logged out. Problems with this approach are that this would need to coordinated with the actual user log in and each interaction from the user would need to update this information.

A second way would be to use a java Bean to maintain a list of "active" users. The bean would need to have application scope so it is available to all users. The method described above could be used and made simpler if the user log in was also managed by this Bean. You could maintain the user list within something like a Vector or HashTable that would then be looked up by the application.


You could also create a Java Bean that would update the database with the logged in status and use the "finalize()" method to update the status to not logged in. The problem with relying on this is you are at the mercy of the Java garbage collection to call the finalize() to flag a user as no longer active. This may not occur for a long time after the user is no longer using the system.


The simplest and quickest way would be to track when the user connected and determine a default "logged out" period to determine whether they are on-line or not.
0
 
LVL 35

Expert Comment

by:girionis
ID: 10060938
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Split points between kennethxu and Binary1

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

girionis
EE Cleanup Volunteer
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introducing Priority Question, our latest feature.
We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question