Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlets basic question

 
Mathur Neni
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess this may be a basic question.

We have a servlet, which has a protected inner class, which contain some attributes. When multiple users are accessing, app is giving wrong info back.

Is there any reason that the attributes in the inner class are being shared when multiple users access. And thus can cause any switched data being displayed to users.

Any suggestions are helpful.

Thanks in advance.
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Access to instance data in servlets needed to be synchonized (whether it's an inner class or a simple primitive). Local (a.k.a. automatic) variables within functions are okay though. So, you might want to try creating your info within the doGet method, or wherever you're doing it.
 
Mathur Neni
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.

Is it the same case in struts action classes also. Just I am curious as we are having another scenario like this?

Thanks,
Neni
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic