File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Static Variable in Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Static Variable in Servlet" Watch "Static Variable in Servlet" New topic
Author

Static Variable in Servlet

Ritesh Raman
Ranch Hand

Joined: Jun 20, 2005
Posts: 34
Is static variable in servlet Thread safe ? please explain.


Thanks,<br />--------<br />SCJP 1.4
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Only local variables are request attributes are thread safe. The rest are all subjected to manipulation by multiple threads unless you synchronize on them.


SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Instead of giving the answer I will just guide you

1. what is a Class variable ? how it is different from instance variable ?

2. what thread safety ?

3. By the time you reach point you yourself can judge.

Hope this is good way to learn.


Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
Ritesh Raman
Ranch Hand

Joined: Jun 20, 2005
Posts: 34
Thanks Srinivasan and Jothi for your reply .
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Static Variable in Servlet
 
Similar Threads
static variable in a servlet
static instance variable in a Java class
Dont declare global variables in Servlet
static variable in servlet - when can we use?
Static & Class Variables