Home Struts Struts2.3.8 Introduction to Struts 2 Framework
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Introduction to Struts 2 Framework

Advertisement
In this video tutorial teaches you Struts 2 framework.
Introduction to Struts 2 Framework - Video tutorial of Struts 2

In this video tutorial we will explain you the features, benefits and architecture of the Struts 2 Framework. The Struts 2 framework is very elegant framework for developing web applications. Applications developed in Struts 2 is very extensible and maintainable; which can be used to develop applications of any size.

Welcome to the world of web application development using Struts 2 Framework.

In this video tutorial I will teach you the Struts 2 framework. You will learn the basics of Struts 2 framework. We will explain you how you can create your first application using Struts 2.3.8 framework. We are using Struts 2.3.8 framework for this tutorial.

Here is the video tutorial of Struts 2 Framework Introduction.

In this session I will explain you the basics of Struts 2 framework and then teach you how to develop your first application using Struts 2 frame work. Topics covered in this session are:

  • Introduction to Struts 2 Framework
  • Struts 1 vs. Struts 2
  • Struts 2 Architecture
  • Struts 2 Lifecycle
  • Features of Struts 2
  • Benefits of Struts 2
  • Downloading and installing Struts 2
  • Writing and testing your first Hello World Application using Struts 2 framework

We will use the Eclipse IDE development of the example application and Tomcat 7 for deploying the application.

Introduction to the Struts 2 framework.

  • Apache Struts is an open-source framework that is used for developing Java web application. Originally developed by the programmer and author Craig R. McClanahan, this was later taken over by the Apache Software Foundation in 2002.
  • Originally Apache Struts 2 was known as WebWork 2.
  • Strut 2 contains the combined features of Struts Ti and WebWork 2 projects that advocates higher level application by using the architecture of WebWork2 with features including a plug-in framework, a new API, Ajax tags etc.
  • Struts 2 is a very elegant and flexible front controller framework based on many standard technologies like Java Filters, Java Beans, ResourceBundles, XML etc.
  • Struts 2 Framework is very extensible and elegant for the development of enterprise web application of any size.

Comparison between Struts 1 and Struts 2 frameworks.

Feature

Struts 1

Struts 2

Action classes

Struts1 extends the abstract base class by its action class. The problem with struts1 is that it uses the abstract classes rather than interfaces.

Struts 2 provides a base ActionSupport class that implements commonly used interfaces. Although an Action interface is not necessary, any POJO object along with an execute signature can be used as an Struts 2 Action object.

Action Form

ActionForm class is mandatory in Struts 1

In Struts 2 same action class is used to hold the form data.

ActionForward

ActionForward is class in Struts 1.

In Struts 2 action returns a string value which is called “Result”.

Struts Configuration

In Struts 1 struts-config.xml is used for configuring the application.

In Struts 2 struts.xml file is used for the application configuration.

Controller

In Struts 1 ActionServlet works as the controller.

In the latest version of Struts 2, StrutsPrepareAndExecuteFilter is used as the controller of the application.

Request processing

In Struts 1 RequestProcessor is used for pre and post processing of the request.

In Struts 2 Interceptors are used for pre and post processing of the request.

Struts 2 Architecture

Struts 2 is an action based framework. It is based on the popular MVC Architecture. The MVC design patterns provides a clean separation of objects into three categories; Model, View and Controller.

Controller: Controller Controls the events passed between Model and the View. All the user request passes through the controller. In Struts all the user requests passes through the controller. Controller is responsible for handling all the requests from the user and finally calling appropriate action.

Model: Model represents the business data. Holds and manages application data such as database data, session data etc..

View: This is the data presentation or the view to be displayed to the user.

Request Lifecycle in Struts 2 applications

  1. User Sends request: User sends a request to the server for some resource.
     
  2.  StrutsPrepareAndExecuteFilter determines the appropriate action: The StrutsPrepareAndExecuteFilter looks at the request and then determines the appropriate Action.
     
  3.  Interceptors are applied: Interceptors configured for applying the common functionalities such as workflow, validation, file upload etc. are automatically applied to the request.
     
  4.  Execution of Action: Then the action method is executed to perform the database related operations like storing or retrieving data from the database.
     
  5.  Output rendering: Then the Result renders the output.
     
  6.  Return of Request: Then the request returns through the interceptors in the reverse order. The returning request allows us to perform the clean-up or additional processing activities.
     
  7.  Display the result to user: Finally the control is returned to the Servlet container, which sends the output to the user browser.

Step to develop applications:

  1. Create JSP page
  2. Write Action class
  3. Map action with view

In the next video tutorial I will teach you how to develop Hello World application in Struts 2.

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 23, 2013

Related Tutorials

Ask Questions?    Discuss: Introduction to Struts 2 Framework  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com