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

FormBeans shared over Sessions/Requests

Gunther Verhemeldonck

Joined: Jan 21, 2004
Posts: 13
I use Struts under Websphere 5.0 and I'm getting really weird behaviour.
When several users login at the same time, my login action seems to receive the same actionform instance most of the time. This means that a user gets the principal of another user after login.
I know that Struts reuses instances, so I implemented the reset() method and made the execute method of the action synchronized. Still no solution ...
Any help is more than welcome
Thanks in advance

Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

Hi Gunther,
I've never seen that kind of problem before. Struts does reuse instances of a form if you keep it in the session scope but each session should get its own instance. The only way I can think of to see the behavior you are seeing is if the form bean used by the action is kept in the application context. I don't think Struts will do that though. Sorry I can't offer you any advice but maybe someone else can.
I do have to ask you to change your publicly displayed name -- the second name needs to be spelled out -- so that it conforms with the Naming Policy. We don't have many rules but the one about names is something that we are really particular about around here (the other being "be friendly" )

Junilu - [How to Ask Questions] [How to Answer Questions]
Gunther Verhemeldonck

Joined: Jan 21, 2004
Posts: 13
All form beans have session scope. We currently use Struts1.1 beta3.
Maybe that's causing the problems. I'll try to convince people to switch to the final 1.1 release, but it's a large project and it's not up to me to decide.
Anyway, your help is appreciated.
Gunther Verhemeldonck

Joined: Jan 21, 2004
Posts: 13
After installing the latest fix-pack for the WebServer-Plugin for Websphere 5, the issue was resolved. We did not (yet) upgrade to the final Struts release.
I agree. Here's the link:
subject: FormBeans shared over Sessions/Requests
It's not a secret anymore!