aspose file tools*
The moose likes Servlets and the fly likes Servlets basic question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlets basic question" Watch "Servlets basic question" New topic
Author

Servlets basic question

Mathur Neni
Ranch Hand

Joined: May 10, 2004
Posts: 33
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

Joined: May 29, 2003
Posts: 1258
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.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Mathur Neni
Ranch Hand

Joined: May 10, 2004
Posts: 33
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlets basic question