tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wade Chandler" <wchand...@redesetgrow.com>
Subject RE: where should i store a attribute
Date Sat, 01 Nov 2003 00:21:56 GMT
That or you can use a GUID.  There are open api's for this publicly
available algorithm.  GUID (Globally unique identifier).  I can send you
some classes if you need it.  I use the api for database keys.  I use
these for keys so I can move them into another database with no issue
(globally unique helps me merge).

Wade

-----Original Message-----
From: Christopher Schultz [mailto:christopher.d.schultz@comcast.net] 
Sent: Friday, October 31, 2003 8:15 AM
To: Tomcat Users List
Subject: Re: where should i store a attribute


Denny,

>> Hello folks, i´m trying to store a database connection in a session 
>> attribute or request attribute, but i must choose a name that just 
>> one thread per time would knowns. Any idea?

> I´m not sure if I understand your question, but hey, I´ll give it a
> shot:
> 
> To get a unique name:
> 
> String uniqueName = String.valueOf(System.currentTimeMillis());
> 
> This will give you unique name. Check out the jdk-javadoc for an
> explanation of this method.

I would not use System.currentTimeMillis, since it might not actually be

unique, and its resolution is different on various platrofmr (i.e. 
Windows has only like a 10 or 100ms resolution, while Linux has 1000ms 
resolution).

If you're looking for something unique to the Thread, why not use the 
thread's hashcode?

String uniqueName = String.valueOf(Thread.currentThread().hashCode());

-chris



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message