wood burning stoves 2.0*
The moose likes Servlets and the fly likes servlet variable scope? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet variable scope?" Watch "servlet variable scope?" New topic

servlet variable scope?

akshat nimbalkar

Joined: Sep 22, 2003
Posts: 1
Can i access all the servlet variables in all the service threads? does Synchronization play any role here?
Joe Ess

Joined: Oct 29, 2001
Posts: 8839

Yes, instance variables would be available. In general this is a Bad Idea since Servlets are multithreaded and accessing instance variables would produce race conditions galore. Synchronizing instance variables to prevent race conditions, on the other hand, reduces the efficiency of multithreading.

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
It is sorta covered in the JavaRanch Style Guide.
subject: servlet variable scope?
Similar Threads
can have the two servlets with same URL pattern?
HttpSession and servlets
SCWCD Cleared with 86%
my servlet says its unavailable in IE