aspose file tools*
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 Java 8 in Action this week in the Java 8 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: 8713

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]
I agree. Here's the link:
subject: servlet variable scope?
Similar Threads
my servlet says its unavailable in IE
SCWCD Cleared with 86%
HttpSession and servlets
can have the two servlets with same URL pattern?