It is good practice to have a delegate class that handles all business logic. This
will not only ensure that you don't run into problems such as you state but also
de-couples your business logic from the Struts framework -- which *should* be used
only for controlling your presentation.
public class SomeAction extends Action {
public void execute(...) {
Delegate delegate = new Delegate(...);
delegate.execute(...);
}
}
The delegate is responsible for all business operations including (any) database calls.
Also make sure that your action class doesn't have any instance variables and only
stack-resident method scope variables. The delegate should have all the information
that would be needed. This way sessions don't step on each other.
Sri
-----Original Message-----
From: Dan Bunea [mailto:danbunea@;linksystems.ro]
Sent: Monday, October 28, 2002 3:14 AM
To: [EMAIL PROTECTED]
Cc: 'Craig R. McClanahan'
Subject: Huge action instance synchronization problem
My problem: I have a search action. When 2 (or more) users submit the search form
simultaniously, because the seach usually takes about 1-2 seconds, the same action
instance is rethrieved to complete the search and sessions are combined like this: the
action makes the search for the first session but does not finish until the second
search is performed and because the resultset is divided into pages and this
divisation is stored into session, both pages with results are put in the second
session, and the second user shall be dispalyed the correct results but the first
shall have null pointer exception because in his session there is no object
representing the divisation of the resultset on pages.
The problem in my opinion is because the same action instance performs the same task
for the 2 users and so the sessions are combined, which is a huge problem, because
like this every method of an action (dispatch
action) that takes a while to complete shall have the same problem.
Please advise me how to solve this problem.
Thank you ,
Dan Bunea
PS Dear Craig , I am sorry to bother you but this problem is very urgent, as the
project is in final stages and this is a potentially huge problem. I have read that
each action is instantiated only once in the RequestProcessor and for each request the
action is rethrieved and its methods executed, but I have also read that this is not
synchronized.
--
To unsubscribe, e-mail: <mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>