my dog learned polymorphism*
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet variable scope?" Watch "servlet variable scope?" New topic
Author

servlet variable scope?

akshat nimbalkar
Greenhorn

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
Bartender

Joined: Oct 29, 2001
Posts: 8876
    
    8

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: http://aspose.com/file-tools
 
subject: servlet variable scope?