File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Thread safety and cookie age question... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Thread safety and cookie age question..." Watch "Thread safety and cookie age question..." New topic

Thread safety and cookie age question...

Amitkumar Dhama
Ranch Hand

Joined: Feb 14, 2005
Posts: 56
hi all following is the explanation given for a question. servlet implementing SingletTreadModel.

Three data elements are always thread-safe, they are:
1.Local variable
2.Request attribute
3.Session attribute
For instance variables, they are NOT safe unless the servlet is a SingleThreadModel servlet, which means there is only one thread accessing one instance at one moment.
For static/class variables, they are always NOT thread safe, even with SingleThreadModel marker.

I got this explanation in iris mock, is it correct?
coz, as far as I know session attributes are not thread safe�

Help me out in clearing this one�

and also please tell me if i'll set cookie age to -1 wgat will happen?

Thanking in advance�

SCJP 1.4, SCWCD 1.4, M.Tech(CSE)
Charith Fernando
Ranch Hand

Joined: Sep 12, 2005
Posts: 67
according to my knowledge i agree with u with the part where session variables are not thread safe..

the only thread safe variables are request attributes and local variables...

for ur second problem relating to cookie age.. when u set it to -1 it lasts forever...

Charith I Fernando<br />SCJP5, SCWCD, SCBCD, BSc(Hons) IS<br />+94 773 263 222 (mobile)
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

Moreover, setting the cookie age to a negative value will cause it to be deleted when the web browser exits (specs, setMaxAge)

[My Blog]
All roads lead to JavaRanch
I agree. Here's the link:
subject: Thread safety and cookie age question...
It's not a secret anymore!