Srinivas Gunturu wrote:
Most of our action classes are extended from a BaseAction class which
initializes protected variables such as session, user bean, ActionForm, request
and response objects inside an init method which is called by decendents in the
execute method.
Sounds like instance variables inside an action class is not a good thing. Is
that the root cause? If so, can you explain how that could cause a problem.
To further elaborate: anything you do inside an Action's "execute"
method (or whatever it's called) or methods called by it must either a)
use variables provided as parameters, b) synchronize access to shared
variables, or c) expect to see the symptoms you're seeing.
So keeping, say, a session as an instance variable doesn't make any
sense, because it will be different for each request: one Action class
services ALL requests to that action. Now, you could do something like
(highly pseudo-codey)
public ActionForward execute(mapping, form, request, response) {
session = request.getSession();
userBean = (UserBeanClass) session.getAttribute("userBeanKey");
moreInterestingExecute(mapping, form, request, response, session,
userBean);
}
but if you do
HttpSession _session;
UserBeanClass _userBean;
public ActionForward execute(mapping, form, request, response) {
_session = request.getSession();
_userBean = (UserBeanClass) _session.getAttribute("userBeanKey");
moreInterestingButBrokenExecute(mapping, form, request, response);
}
public ActionForward moreInterestingButBrokenExecute(mapping, form,
request, response) {
brokenValue = _session.getAttribute("anyKey");
}
you will see the behavior you're seeing: if the Action serves another
request it will set the _session variable to the new request's session,
which will almost always be the Wrong Thing To Do.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]