• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What are the differences between strust 1 and struts 2 from developer's perspectice

 
Monica Shiralkar
Ranch Hand
Posts: 866
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the differences between struts 1 and struts 2 from developer's perspective. 2 differences I can point out are:

1) For checking on ever page whether user has logged in or not Struts 1 uses Login Filters whereas in Struts 2 we would do this using Interceptors.
2) Data from form does not need to have properties in form bean.Instead it should have properties in Action class

3) Developer does not need to care about synchronizatin in struts 1 whereas in struts 2 one needs tp care about synchronization.

What else does developer doing transition from struts 1 to struts 2 need to keep in mind.

thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
 
Monica Shiralkar
Ranch Hand
Posts: 866
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. Is the below understanding correct?

In struts 1: execute method was compulsory.For each small operation a separate Action class should be created with its execute method. Suppose it is UserRegistration.Then for addUser,deleteUser,modifyUser,listUserdifferent classes should be created.

In Struts 2: Since execute method is not compulsory. A single action class will have methods for addUser,deleteUser,modifyUser ,listUser.So in case of struts 2 for UserRegistration there can be just 1 action class and all methods inside this. In such a case when all functionality will be inside methods addUser,deleteUser,modifyUser ,listUser which would be returning success failure etc then what would the execute method be doing?Or should it be omited in such a case.
 
Joe Ess
Bartender
Posts: 9320
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Monica. Shiralkar wrote:what would the execute method be doing?Or should it be omited in such a case.


If you have no need for the execute method, it may be omitted.
 
Arun Giridhar
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Monica. Shiralkar wrote:
Developer does not need to care about synchronizatin in struts 1 whereas in struts 2 one needs to care about synchronization.


I couldn't understand this can someone clarify me , this point seems to be vaguely written.
 
Joe Ess
Bartender
Posts: 9320
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arun Giridhar wrote:
Monica. Shiralkar wrote:
Developer does not need to care about synchronizatin in struts 1 whereas in struts 2 one needs to care about synchronization.


I couldn't understand this can someone clarify me , this point seems to be vaguely written.


I'm not sure what Monica means about synchronization. If she means the thread model, one must understand how Struts works in order to keep users from interfering with each others requests. In Struts 1, there is only one instance of an Action created, so one must be careful to either create resources in the execute method or use the synchronize keyword to limit access. If one uses instance-level resources, it is very easy to create race conditions.
In Struts 2, an instance of the action is created with each request, so one is not so concerned as much with thread safety (though one can certainly create problems, particularly with static resources).
 
Monica Shiralkar
Ranch Hand
Posts: 866
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. And yes I meant the above with synchronization.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic