Struts 2 Tutorial and Examples

Best Struts 2 Tutorial and Examples, Learn Struts 2 framework with the help of many examples on our website.

Struts 2 Tutorial and Examples

Struts 2 Tutorial and Examples with source code

Struts 2 is open source MVC framework in Java which very popular and used by Java developers to develop applications. In this section we are giving your many Struts 2 tutorial and examples for learn it from beginning.

Pre-requisites for learning Struts 2 Framework

Struts 2 framework is for creating user interface for web application and following are pre-requisites for learning this framework.

Even if you don't know Spring framework you can start learning Struts 2 framework.

At the time of writing of this tutorial most latest Struts 2 framework as Apache Struts 2.5.10.1 GA which was released on 7 March 2017. This version of Struts was released with a fix for the bug which related to the file upload using Jakarta Multipart parses. This fix removes the potential security vulnerability of Possible Remote Code Execution during file upload.

Struts 2 framework can be integrated with modern AnguarJS, jQuery and other front end frameworks to develop modern web applications.

Struts 2 Tutorial and Examples

Here are the best tutorials of Struts 2:

Beginning Struts 2.2.1

  1. Features of Struts 2.2.1 - Learn features of Struts 2 Framework
  2. Understanding MVC design pattern - MVC Design pattern is standard following in developing modern web applications
  3. Developing Hello World application - This tutorial will teach you to make your first Struts 2 Application
  4. Running and testing the example - Learn How to run your first Struts 2 application?
  5. Struts 2 hello world application using annotation - Annotation is great way to write program quickly, in this tutorial we are going to develop Struts 2 Hello world application using annotation.
  6. Running and testing the example - In this section I will teach you to run the example program.
  7. Advance Struts Action - For detail about the Advanced Struts 2 concepts.

Struts Action

  1. Introduction to Action interface - Introduction to the Action interface in Struts 2
  2. Introduction to ModelDriven interface with example - Learn about the model driven architecture
  3. Example of ActionSupport class - How to use ActionSupport class in your Struts 2 application?
  4. Implementing Actions in Struts 2 - Example of implementing Actions in Struts 2
  5. Chaining Actions in Struts - What is chaining in Struts 2? Learn Action Chaining with examples.
  6. Configuring Actions in Struts application - This section teaches you to configure the Actions in a Struts 2 application.

Login Form Application

  1. About Struts 2.2.1 Login application - You can now learn to make the form based application and the simple one is the login application.
  2. Create JSP file - This is the first step in creating login application in Struts 2
  3. Create Action class - Action class is used to handle the request from user.
  4. Add configuration in struts.xml file - Let's see how to configure browser request, Action and JSP page in our application?
  5. Build and test application - Finally application coding is ready and we are about to build and run the application.

Results

In this section you will learn various types of action results in Struts 2 with example code.

  1. Result interface in Struts 2.2.1 - Example and uses of result interface in Struts.
  2. Chain Result Example - How to chain result in Struts 2 application?
  3. Dispatcher Result Example - Example and explanation of result dispatcher in Struts 2.
  4. Redirect Result Example - Example of redirect result in Struts 2
  5. Redirect Action Result Example
  6. Stream Result example
  7. Introduction to XSL Result and its example
  8. Learn how to use PlainText Result
  9. Tiles Result Example in Struts 2.2.1
  10. Introduction to PreResultListener
  11. Pagination example in Struts 2.2.1

Validation in Struts 2.2.1 application

In this section you will learn how to validate the Struts 2 application using validation framework as well as through custom code. Validating user input is one of the major work for developers and they spend lot of time in writing code for user input validation. These standard validators that comes with the Struts framework that can be used.

  1. Introduction to Validation Interceptor - This section introduces you with the validation interceptor of Struts 2 framework.
  2. Client side Validation - Understanding client side validation in Struts 2
  3. Server side Validation - Understanding serve side validation in Struts 2
  4. AJAX Validation - Discussion about the Ajax validation in a Struts 2 application.
  5. Using Field Validators - Tutorial and example of using the field validator in Struts 2
  6. Using Non Field Validators
  7. Login form validation example - How to validate login form in Struts 2? Learn it with using various validation concepts of Struts 2

Struts 2.2.1 Tags

There are many different types of tags/tag library that comes with the Struts 2 framework. In this section we are learning to use these tag libraries to create the UI Interface for the application.

  1. Type of Struts 2.2.1 tags - This section explains you the various types of tags in Struts 2
  2. Example of Generic Tags
  3. Example of UI Tags
  4. Example of Themes and Templates
  5. Example of Ajax Tags
  6. Example of OGNL
  7. How to use Checkboxes in Struts 2.2.1 applications
  8. Example of Iterator tag in Struts 2.2.1
  9. Learn how to format dates and numbers in Struts 2.2.1
  10. Skinning example in Struts 2.2.1
  11. How to handle multiple Submit Buttons in your application

Ajax Application in Struts 2.2.1

In this section we are going to use Struts 2 framework to make simple Ajax application.

  1. Introduction to Ajax
  2. Ajax support in Struts 2.2.1
  3. Developing Simple Example

Interceptors in Struts 2.2.1

Learn to use different types of Interceptors in your application. You will learn to use the file upload interceptor and ExecuteAndWait interceptors of Struts 2 framework.

  1. Introduction to AOP and Interceptor
  2. Introduction to the Interceptor interface in Struts 2.2.1
  3. How to configure interceptors in struts.xml
  4. How to configure Interceptor Orders in Struts application
  5. Example of File Upload Interceptor
  6. How to use ExecuteAndWait Interceptor

Type conversion

Type conversion is the concept of converting one type of data into another type. Here you will learn about the type conversion in Struts 2.

  1. Introduction to Type conversion in Struts
  2. Type conversion example

Test-driven Development in Struts 2.2.1 application

Unit testing of the web based application is very import part and in this section we are going to learn about the unit testing of Struts 2 application.

  1. JUnit - JUnit is a Java based framework which is used for unit testing Java application. In this section we are going to learn the steps to unit test Struts 2 application.
  2. Using Spring mock objects
  3. Writing unit tests
  4. Test Actions

Database driven application in Struts 2.2.1

Learning of any framework is not complete without learning its integration with database. Struts 2 is MVC framework for writing user interface in a web application. In this section we will learn how to connect it to database and access the data.

  1. Creating database
  2. Adding database capability in Struts 2.2.1 application
  3. Creating model classes
  4. Writing action classes
  5. Writing JSP files
  6. Configuring in struts.xml file
  7. Running and testing application

Miscellaneous Examples

Finally we have few important examples you should learn to understand Struts 2 framework in a better way.

  1. Struts PDF Generating Example
  2. Struts 2 Interceptor Example
  3. Struts Online Test application
  4. Struts2.2.1 and hibernate integration application
  5. Shopping Cart Application
  6. Mailing Application
  7. Hibernate criteria example using struts2

After completing these Struts tutorial and examples you will be able to work on the commercial projects. You will be able to develop applications for clients using Struts 2 and any database access framework.

Visit Struts Tutorials home page for finding more tutorials of Struts 2.