Forums Register Login

Saving Session objects in a Hashtable

+Pie Number of slices to send: Send
What I am trying to do.
I want a user to log into my application. I will get their session with the request object and save it in a HashTable with a name-value of - for example ("Jarrod"/jlSession), this hashtable will be saved in the servletcontext.
Simple enough you might ask, now the trick!!
I want another client to access my web app and be allowed to refresh the first clients session (I have my reasons ).
Does anyone out here know if I can get the original session out of the hashtable and somehow refresh it as if I were calling request.getSession() from first Client? Basically, I don't want that first user to timeout, I want their session to be refreshed by the second client somehow.
Thanks Java Ranchers,
Jarrod
+Pie Number of slices to send: Send
You can certainly hang on to additional references to a session but there may be some problems. I don't see any method in HttpSession to refresh the timestamp - I suspect that mechanism is hidden and may vary between implementations.
There is no reason you can't implement your own equivalent to HttpSession managed by some singleton class having a timer Thread. Then you can do what you want.
Bill
+Pie Number of slices to send: Send
Bill,
I'm a little uneasy about creating my own class that implements HttpSession. I'll be using the Servlet Container in WebLogic 6.0, it potentially may even be clustered further complicating things. I'd like to take advantage of the SessionListener interface as well.
Do you know if a call to set the timeoutvalue of the session may actually refresh the session. I suppose I could test and I'm being lazy. But this would solove my prob.
Thanks for your input.
Jarrod
+Pie Number of slices to send: Send
I didn't mean you should implement HttpSession, just the functionality. All you need is a Hashtable, and a few long to represent time stamps to get similar functionality.
As for the setTimeoutValue call, since it is not specified in the API, you can't count on all implementations working the same way.
If you have WebLogic and may have clusters, I would certainly not try anything tricky.
Bill
+Pie Number of slices to send: Send
Thanks for your help Bill. Your right there is nothing stopping me from managing the state of the user. Now I guess I have to learn how to implement something like the sessiontimeout function with sessions. Any ideas, you'd be a big help if you point me in the proper direction.
I guess I could give you a little background on what I'm doing just to make it a little more interesting for you. I'm researching a way to build a Single Sign On application for my corporation. Basically a user will pass their username/password to a servlet. The username/password will be verified and a user profile will be built and saved in the application scope. Now when a user goes from app to app within the corporation those app's will call the SSO application giving the username among other things in the request. The SSO application will check to see if he/she is logged in, refresh the user's session and send a response back to the calling app telling them the user is logged in.
Thanks again,
Jarrod
The longest recorded flight time of a chicken is 13 seconds. But that was done without this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1212 times.
Similar Threads
User Txn - Lookup problem
Command Line Parameters or GUI Start up
Dan's Question
making available a single session at any point of time
User Authentication
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 15:42:19.