File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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: 9189

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.

[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: servlet variable scope?
It's not a secret anymore!