File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Basic question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Basic question" Watch "Basic question" New topic

Basic question

Mathur Neni
Ranch Hand

Joined: May 10, 2004
Posts: 33
I guess this may be a basic question.

We have a Action class, which has a protected inner class, which contain some attributes. When multiple users are accessing, app is giving wrong info back (some others user data). Basically the same kind of problem happened in servlet and that was cleared by bringing attributes into the doGet method.

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.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The important thing to remember is that an Action class, like a servlet will be used by multiple threads, and must be written as thread safe. Without looking at your Action class, it's not possible to comment on why your inner class isn't thread safe, but it apparently isn't. An inner class isn't inherently non-thread-safe, but it is certainly possible to access an inner class in a non-thread-safe way.

Consultant, Sima Solutions
I agree. Here's the link:
subject: Basic question
It's not a secret anymore!