• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with single servlet instance

 
Chetan Sahasrabudhe
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When servlet is not SingleThreadModel for each servlet class only one instace is created and same reference is used in multiple threads that are responding to the request.

If I endup creating a servlet class attribute then this model will go on toss.
With single istance reference used across the threads my class attribute will start acting like a global variable or kind of static value.

Is there a way that java through compile time rules stop developer from creating servlet class attributes.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The compiler will not complain because syntax is not being broken.

It's simply poor design to put class members (attributes) in a servlet. A servlet's purpose is not to hold state.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic