• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Saving Session objects in a Hashtable

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Jarrod Littlejohn
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Jarrod Littlejohn
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
He's my best friend. Not yours. Mine. You can have this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic