2010 02-19, struts 2.0 vs. spring comparison, v3
DESCRIPTION
TRANSCRIPT
© 2007 Accenture All Rights Reserved.
DCN Java Capability Webinar Programme 2010
Comparing Struts 2.0 with Spring
Accenture –Confidential 2
Session Objectives
The objectives of this session:
To know about the Struts 2.0 and Spring Framework features
Compare Struts 2.0 with Spring
Accenture –Confidential 3
Session Topics
What is Struts 2.0?
Prominent changes in Struts 2.0
Features of Spring 2.x and later
Architectural benefits of Spring
Comparing Struts with Spring
Advantages of Spring over Struts 2.0
References
Accenture –Confidential 4
What is Struts 2.0 all about? The Struts 2 framework is designed for the compilation of the entire development
cycle which includes the build, development and maintenance of the whole application.
First the web browser requests a resource for which the Filter Dispatcher decides the suitable action. Then the Interceptors use the required functions and the Action method executes all the functions like storing and retrieving data from the database. Finally, the result can be seen on the output of the browser in HTML, PDF, images or any other.
Configuration is based on the XML format.
Model-View-Controller (MVC) is the core of struts which allows as easy building of the web application.
Any class can be used as an action class, as opposed to the earlier restriction of extending the Action class from an API.
Request handling in any action class makes it easy to customize when required.
Struts 2 Actions are Spring friendly, making for easy Spring Integration.
Accenture –Confidential 5
Session Topics
What is Struts 2.0?
Prominent changes in Struts 2.0
Features of Spring 2.x and later
Architectural benefits of Spring
Comparing Struts with Spring
Advantages of Spring over Struts 2.0
References
Accenture –Confidential 6
Prominent changes in Struts 2.0
Action Classes are no longer required to extend the Struts Action class; any Plain Old Java Object (POJO) with an execute method can be tagged as a Struts 2 Action Object.
Struts 2 Action objects are instantiated for each request, so there are no thread-safety issues.
Struts 2 Actions can be tested by instantiating the Action, setting properties, and invoking methods.
Dependency Injection support makes testing simpler.
No tight coupling on HTTPServletRequest and HTTPServletResponse.
Struts 2 uses Action properties as input properties, eliminating the need for a second input object.
Accenture –Confidential 7
Prominent changes in Struts 2.0
Struts 2 can use the JavaServer Pages Standard Tag Library (JSTL), but the framework also supports a more powerful and flexible expression language called Object Graph Notation Language (OGNL).
Struts 2 uses a "ValueStack" technology so that the taglibs can access values without coupling your view to the object type it is rendering.
Struts 2 supports manual validation via the validate method and the XWork Validation framework.
Struts 2 has Stateful checkboxes.
Struts 2 has added interactivity and flexibility with AJAX tags.
Struts 2 has integrated profiling to find where the cycles are going.
Accenture –Confidential 8
Session Topics
What is Struts 2.0?
Prominent changes in Struts 2.0
Features of Spring 2.x and later
Architectural benefits of Spring
Comparing Struts with Spring
Advantages of Spring over Struts 2.0
References
Accenture –Confidential 9
What is there in Spring 2.x and later?
Spring makes Java EE easier to use.
Spring reduces to zero the complexity cost of using interfaces.
JavaBeans offer a great way of configuring applications.
Provides easier testability of the components.
Provides a lightweight container with a centralized and automated configuration.
Simple transaction management facilities.
Provides a JDBC abstraction layer.
Accenture –Confidential 10
What is there in Spring 2.x and later?
Spring 2.5 introduced the annotation-based configuration.
Autowiring has been enhanced in such a way that a property can be autowired through the setter, constructor or through any method.
Annotations were introduced for web MVC.
Spring 3.0 has introduced Spring annotations, @MVC annotations and Spring Expression Language.
Accenture –Confidential 11
Session Topics
What is Struts 2.0?
Prominent changes in Struts 2.0
Features of Spring 2.x and later
Architectural benefits of Spring
Comparing Struts with Spring
Advantages of Spring over Struts 2.0
References
Accenture –Confidential 12
Architectural benefits of Spring
Spring effectively organizes the middle tier objects. Spring takes care of the plumbing of the code blocks.
Spring reduces the increase in the Singletons as seen in other frameworks.
Custom property file formats are reduced with the consistent configuration.
Design of Spring leads to easy testability of the code.
Spring provides a lightweight infrastructure.
Spring aims at building the application with POJOs.
Spring makes the usage of existing technologies simpler and provides a simpler programming model.
Accenture –Confidential 13
Session Topics
What is Struts 2.0?
Prominent changes in Struts 2.0
Features of Spring 2.x and later
Architectural benefits of Spring
Comparing Struts with Spring
Advantages of Spring over Struts 2.0
References
Accenture –Confidential 14
Comparing Struts with Spring
Feature Struts 2.0 Spring
Application development support Doesn’t support standalone application development
Supports standalone application development
MVC-based web application Supports MVC-based application development strongly
Supports MVC-based web application development
AJAX support Has a built-in support for AJAX Does not have default support for AJAX
Support for POJOs as components
Supports POJOs as components Based on POJOs as the basic framework components
Accenture –Confidential 15
Comparing Struts with Spring
Feature Struts 2.0 Spring
Rich tag library Has rich tag library support that can generate form fields
Does not have a rich tag library
Knowledge Base and community Has wide availability of experienced professionals and knowledge base
Traditionally behind Struts, but is now catching up to its pace
Transaction management and security
Doesn’t have extensive support for transactions or security out of the box
Supports transactions as well as application security features
Stateful checkboxes Supports stateful checkboxes Does not have stateful checkboxes
Accenture –Confidential 16
Session Topics
What is Struts 2.0?
Prominent changes in Struts 2.0
Features of Spring 2.x and later
Architectural benefits of Spring
Comparing Struts with Spring
Advantages of Spring over Struts 2.0
References
Accenture –Confidential 17
Advantages of Spring over Struts 2.0
Spring provides the complete solution for the Java SE/EE application as compared to the Struts framework which concentrates on the MVC-based web application solution.
Spring framework has transaction support and security features which are available out of the box where as Struts 2.0 doesn’t have the support for the same.
Spring provides a lightweight framework as compared to Struts.
Spring provides an easy integration with the other frameworks like Hibernate and iBatis. Struts requires usage of plug-ins for the integration.
Spring has a Web Flow module which is used for the navigational control of the UI flow in an application.
Spring provides a two-level JDBC abstraction that significantly eases the effort of writing JDBC-based DAOs.
Accenture –Confidential 18
Session Topics
What is Struts 2.0?
Prominent changes in Struts 2.0
Features of Spring 2.x and later
Architectural benefits of Spring
Comparing Struts with Spring
Advantages of Spring over Struts 2.0
References
Accenture –Confidential 19
Struts 2 in Action – by Donald Brown, Chad Michael Davis and Scott Stanlick
Spring in Action – by Craig Walls
RoseIndia Tutorials – http://www.roseindia.net
SpringSource Community – http://www.springsource.org/
TheServerSide.com – http://www.theserverside.com/
Apache Struts 2 release information – http://struts.apache.org/2.x/index.html
References