aspose file tools*
The moose likes Struts and the fly likes What are the differences between strust 1 and struts 2 from developer's perspectice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "What are the differences between strust 1 and struts 2 from developer Watch "What are the differences between strust 1 and struts 2 from developer New topic
Author

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

Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 644
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

Joined: Jan 10, 2002
Posts: 61413
    
  67

http://struts.apache.org/release/2.2.x/docs/comparing-struts-1-and-2.html


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 644
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

Joined: Oct 29, 2001
Posts: 8927
    
    9

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Arun Giridhar
Ranch Hand

Joined: Mar 10, 2012
Posts: 147

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.


hate Professionalism . Join the http://2014.hack.lu/index.php/Main_Page
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

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

Joined: Jul 07, 2012
Posts: 644
Thanks. And yes I meant the above with synchronization.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What are the differences between strust 1 and struts 2 from developer's perspectice