Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

accessing class and static variables in servlet class

843841Jun 11 2003 — edited Jun 12 2003
I haven't used servlets much before so I'm hoping all you smart folks out there can help me clear up a few things :-)

I have a servlet that has a bunch of class variables (they are declared outside of the doGet and doPost methods). I notice that if I invoke the servlet once, which causes it to assign some values to those variables, and then invoke it again shortly after, the values which were assigned the first time carry over. I'm confused now. Does this mean that there will be a concurrency problem if someone else on another machine is invoking the servlet at the same time that I'm invoking it?

Another related question: If I have a static class variable and assigned it some value, would every instance of the servlet, even those started by a person using another machine, be able to access that value?

Sorry if the questions are dumb. I would really appreciate any clarifications. Thanks a lot.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 10 2003
Added on Jun 11 2003
15 comments
660 views