Java Struts 2 Tutorials For Beginners and Professionals
In this Java Struts 2 Tutorials For Beginners and Professionals article series, we are going to discuss all the basic, intermediate, and advanced concepts of Struts with simple as well as real-time examples.
This Struts tutorial is for whom?
This Struts tutorial is designed for beginners, students, and professional Java developers who want to learn and enhance their Java Struts Framework skills step by step from scratch. These tutorials provide a hands-on approach to the subject with step-by-step program examples that will assist you to learn and put the acquired knowledge into practice.
What you will learn from this Java Struts Tutorial?
Introduction
Basic MVC Architecture
What are Struts?
Struts 2 Framework
Struts 2 Features
Struts 2 Advantages and Disadvantages
Why are struts so popular?
Struts 2 based on MVC 2 architecture
Struts 1.x vs Struts 2.x Differences
Model 1 and Model 2 (MVC) Architecture
Model 1 Architecture
Advantages of Model 1 Architecture
The Disadvantage of Model 1 Architecture
Model 2 (MVC) Architecture
Advantages of Model 2 (MVC) Architecture
The disadvantage of Model 2 (MVC) Architecture
The solution of Model 2 Architecture: Configurable MVC Components
Struts 2 – Components
Action Beans
Action servlets
ActionForm beans and Custom Tags
Interceptors
Value Stack / OGNL
Results / Result types
View Technologies
Action context
ActionInvocation
Struts 2 Architecture and Flow
Struts 2 basic flow
Struts 2 standard flow (Struts 2 architecture)
How Struts Works
Struts 2 Request Life Cycle
Struts 2 – Environment Setup
Step 1 – Setup Java Development Kit (JDK)
Step 2 – Setup Apache Tomcat
Step 3 – Setup Eclipse (IDE)
Step 4 – Setup Struts2 Libraries
Steps to Create a Struts 2 Application
Steps to Create Struts 2 Application Example
Create the directory structure
Create input page
Provide the entry of Controller in the web.xml file
Create the action class
Map the request with the action in the struts.xml file and define the view components
Create view components
load the jar files
start the server and deploy the project
Struts 2 – Creating First Struts 2 Example
Create a Dynamic Web Project
Create an Action Class
Create a View
Create the Main Page
Configuration Files
Enable Detailed Log
Procedure for Executing the Application
Create a struts 2 application in MyEclipse
Example to create a Struts 2 application in MyEclipse
Create a web project
Add struts 2 capabilities
Create input page
Create the action class
Map the request with the action in the struts.xml file and define the view components
Create view components
start the server and deploy the project
Struts 2 Core Components
Struts 2 Interceptors
Advantage of interceptors
Struts 2 default interceptors
Struts 2 ValueStack
ValueStack Interface
Methods of ValueStack interface
Struts 2 ActionContext
Struts 2 ActionInvocation
ActionInvocation Interface
Methods of ActionInvocation Interface
Struts 2 OGNL
Struts 2 Action Interface
Action Interface
5 Constants of Action Interface
Example of Struts Action that implements Action interface
ActionSupport class
Struts 2 – Configuration Files
The web.xml File
The Struts.xml File
The Struts-config.xml File
The Struts.properties File
Struts 2 Elements
Package element
Attributes of the package element
action element
Attributes of the action element
result element
Attributes of the result element
Other elements
Multiple Configuration File
Example to create multiple configuration files
Define entry of multiple configuration files in struts.xml
Create configuration files
Struts 2 Multiple Namespace
Define multiple namespaces in struts.xml
Struts 2 – Actions
Create Action
Create a View
Execute the Application
Create Multiple Actions
Struts 2 Interceptor
Struts2 Framework Interceptors
How to Use Interceptors?
Create Custom Interceptors
Create Interceptor Class
Create an Action Class
Create a View
Create the Main Page
Configuration Files
Stacking Multiple Interceptors
Struts 2 Custom Interceptor
Example to create custom interceptor in struts 2
Create an interceptor (must implement Interceptor interface)
Define the entry of interceptor in the struts.xml file
Struts 2 params interceptor
Internal working of params interceptor
Parameters of params interceptor
Example of params interceptor
Struts 2 default stack interceptors
Struts 2 execAndWait interceptor
Parameters of execAndWait interceptor
Example of execAndWait interceptor without wait result
Example of execAndWait interceptor with wait result
Struts 2 prepare interceptor
Parameters of preparing interceptor
Action class
Struts 2 model-driven interceptor
Parameters of model-driven interceptor
Example of model-driven interceptor
Struts 2 Exception Handling – exception interceptor
Understanding the internal working of exception interceptor
Parameters of exception interceptor
Example of exception handling in struts 2
Displaying exception
Example of exception handling
Global Exception Mappings
Struts 2 – Results & Result Types
The Dispatcher Result Type
The FreeMaker Result Type
The Redirect Result Type
Struts2 File Upload
Parameters of file upload interceptor
Image upload example using struts 2
Struts 2 – Database Access
Struts 2 – Type Conversion
Struts 2 – Value Stack/OGNL
The Value Stack
ValueStack Objects & Description
ValueStack Methods & Description
The OGNL
ValueStack/OGNL Example
Struts 2 – Validations Framework
How does this Validation work?
XML Based Validation
Struts 2 Custom Validation
Workflow Interceptor
Validatable interface
ValidationAware interface
Methods of ValidatationAware interface
Steps to perform custom validation
Example to perform custom validation
Defining action level error message
Struts 2 Validation by Bundled Validators
validation interceptor
Advantages of Bundled Validators
Bundled validators:
Required string validator
String length validator
Email validator
Date validator
int validator
double validator
url validator
regex validator
Two ways to use bundled validators
Plain-Validator (non-field validator) Syntax
Field-Validator Syntax
Struts 2 Ajax Validation
JSON Validation Interceptor
Steps to perform AJAX Validation
Example to perform Ajax validation
AJAX
What is Ajax?
How Ajax is different?
Who is using Ajax?
Some use for Ajax interactions
Some challenges of this approach
JQuery
Why JQuery?
Features of JQuery
JQuery Event Methods
JQuery AJAX Methods
Struts 2 – Control Tags
The If and Else Tags
The Iterator Tags
The Merge Tag
The Append Tag
The Generator Tag
Struts 2 – Data Tags
The Action Tag
The Include Tag
The Bean Tag
The Date Tag
The Param Tag
The Property Tag
The Push Tag
The Set Tag
The Text Tag
The URL Tag
Struts 2 – The Form Tags
Simple UI Tags
Group UI Tags
Select UI Tags
Struts 2 – The Ajax Tags
Struts 2 Aware Interfaces
ServletActionContext class
Methods of ServletActionContext class
How to obtain an instance of HttpSession?
SessionAware Interface
SessionMap class
Methods of SessionMap class
Example of SessionAware interface
ServletContextAware Interface
Usage of ServletContextAware interface
Example of ServletContextAware interface
Struts2 – Localization, internationalization (i18n)
Resource Bundles
Localization Example
Parameters of i18n interceptor
Example of i18n interceptor
Struts 2 Zero Configuration by convention
Example to create a zero-configuration file by convention
Struts 2 Annotations Example
Annotations used in Struts 2 application
Example of struts 2 application using annotations
Struts 2 Tiles Framework Integration
Advantage of tiles framework
Steps to create tiles application
How to define multiple tiles files in Struts 2 application
Struts 2 – Annotations
Struts 2 Annotations Types
Struts 2 – Themes & Templates
Selecting Themes
How does the Theme work?
Creating a New Theme
Development:
Struts 2 Registration Form Example
Struts 2 Login and Logout Example
Struts 2 CRUD Operations Example
Struts 2 – Sending Email Example
Struts 2 Integration
Struts 2 & Spring Integration
Struts 2 & Tiles Integration
Struts 2 and Hibernate Integration
Struts Interview Questions
What do we expect from you?
We will do our level best to cover all the Java-Struts concepts, but in the meantime, if you have any specific concept in your mind that you want us to cover, then please leave it as a comment in the comment box, and we will definitely discuss that concept(s) in this Java Struts Tutorials course.
Prerequisites to Learn Servlets:
It is mandatory to have Knowledge of Core Java and the basics of HTML.
Finally, your valuable feedback is very important and means a lot to us. So, if you have a few minutes, then please let us know your thoughts and feedback on this Java Struts Tutorials course. Please join our Telegram Channel to learn more and clear your doubts about Java Advance Java, Servlets, JSP, JDBC, and Java Frameworks like Spring, Hibernate, and Struts. Also, join our Java Facebook Group to learn and share your thoughts on Java.