struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Weigen Liang <>
Subject why only one instance of Action class (Action class thread safety)
Date Mon, 05 May 2003 05:49:14 GMT
The current Struts framework creates only one instance for each Action
class, and uses that instance to serve all the relevant requests. This
makes the Action class thread safety a big issue for newer users of the
Struts framework. The struts user mailing list has many, many such
questions from Struts users. This is similar to servlet itself. The
servlet spec has the SingleThreadModel to "try" to solve this problem,
but as we know, this does not really work. 

If one instance of Action object is created for EACH request, then we
would not have this threading issue. This instance would be tied to a
request object and a response object, and has life span of that
particular request. The class would be like this:

public class Action {
   public Action(ActionMapping mapping, ActionForm form, 
      ServletRequest request, ServletResponse response) {

   public ActionForward execute() {

   private ActionMapping mapping;
   private ActionForm form;
   private ServletRequest request;
   private ServletResponse response;

   // plus other instance variable for this particular request

Considering that a significant percentage of Struts users have limited
understanding of thread safety, removal of such a concern from the
framework would certainly help the users. 


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message