• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with instance variable in servlet  RSS feed

 
sirisha makkapati
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know f there is instance variables in Servlet we need to keep them thread Safe or else same varible will access by each Request.Is Any Disadvanges are there while declaring the instance variables in Servlets.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, they're not thread-safe.

Rule of thumb:
Until you know exactly what you're doing and have a real compelling reason to do so, DON'T create any instance variables in your servlets.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!