Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sessions...in java app, not jsp or servlets

Status
Not open for further replies.

webIntern

Programmer
Nov 22, 2002
40
US
Does anyone know of a way to keep a property accessible throughout a user session in a Java app? I'm writing a Java native client app to access remote .NET services (web services). The services issues a session ticket upon login to implement security...this ticket needs to be accessible to all objects in the client app. In addition, this ticket needs to be "renewed" every 10 minutes or so.

Any ideas?
 
Either -
- write the value to a file (and maybe syncronize the file access for thread safety)
- create a custom object to hold your data that implements java.io.Serializable , and serialize/deserialize your object to a file (and definitely sunc it)
- If you have a J2EE server running, use an EJB (mapped to a JNDI lookup) to hold your data.
 
If I understand your question properly, I believe you can use session attributes for what you want to do.
 
TerribleTerry :
He wants it for a standalone Java application, not a webapp running in a servlet container ...
 
Sedj:

Thanks for your input. The ticket is being saved as a "ticket" object and set in the soap header. My only problem now is figuring out how to "renew" the ticket every ten minutes...
 
Ok, now my question is how to tell if the user has been inactive/active over a certain amount of time?

 
You can use java.util.Timer to refresh every ten minutes (or 9 minutes to be safe).

long renewDelay = 10*1000; // ten minutes
boolean isDaemon = true; // kill timer thread when application exits
TimerTask refreshTask = new TimerTask() {
public void run() {
// refresh ticket
}
};
new Timer(isDaemon).schedule(refreshTask, renewDelay, renewDelay);

Sean McEligot
 
plork123,

This thread is almost 18 months old ... please do not dredge up old threads if you mean to only reply to the original poster - who is probably long gone by now (and hasn't even logged in to tek-tips for 5 months).

Thanks.

--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top