my dog learned polymorphism*
The moose likes Servlets and the fly likes servlet's thread safe 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 Watch "servlet New topic

servlet's thread safe

David Qiu

Joined: May 14, 2001
Posts: 8
i am doing a project which allows more than one person to access a servlet, which results in multiple servlet instances at the same time. and i think some objects may not be in a consistent way, they are servlet class variables, request attributes, session attributes and context attributes. is that right? do i need to synchronized these objects? thanks in advance
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1506
Yes, you can either synchronize any access to those variables, or implement the "SingleThreadModel" interface.

So much trouble in the world -- Bob Marley
I agree. Here's the link:
subject: servlet's thread safe
Similar Threads
LDAP search returns collection of Attributes objects
Question on attributes
someone pls explain me this statement...
Difference. between ServletContext and Session Attributes