Skip to main content

What is Struts framework in Java?


Struts framework helps for developing the web based applications. Struts java framework is one of the most popular framework for web based applications.Java servlet, JavaBeans, ResourceBundles and XML etc are the Jakarta commons packages used for accomplishing this purpose. This is an open source implementation of MVC pattern for the development of web based application. The features of this type of framework are,

More robust or reliable architecture
Helps for development of application of any size
Easy to design
Scalable
Reliable web application with java.

Struts Framework

When a request happens the parameters interceptor passes the requested data to the ValueStack. After transferring the request the OGNL do the job of changing the string based form data to their related java types. OGNL complete or do this by using the set of available built-in type converters. After that when the results are generated the OGNL converts the java types of the property on the ValueStack to the string-based HTML output. ActionContext is act as thread local which helps the values stored in the ActionContext are unique per thread, this makes the Struts 2 actions thread safe.

Strut implements the Model-View-Controller (MVC) design pattern.


Structure of Struts Application

Model: – The model includes the core of the application’s functionality. It wraps the state of the application. Sometimes the only functionality it contains is state. Model category not bothered about the view or controller category.
View: – The view gives the presentation of the model. It is the look of the application. The view can access the model getters, but it has no knowledge of the setters. In addition, it knows nothing about the controller. The view should be notified when changes to the model occur.
Controller: – The controller reacts to the user input. It creates and sets the model.
The MVC implemented by the action, result and FilterDispatcher respectively. In MVC the controller’s job is to map the user request to appropriate action and this job is done by FilterDispatcher. The model includes the data and the business logic and the model is implemented by the action component. The presentation component of the MVC pattern is view and view is implemented using JSP, Velocity Template, Freemaker or some other presentation-layer technology.

Struts components

1) Action handler:- The action handler interacts with other layers

2) Result Handler: – The result handler actually dispatches the request to view.

3) Custom Tags:- The custom Tags are used render the dynamic content

4) Interceptors: – An interceptor permits to adding some custom logic such as authentication, file upload to an action. Interceptors code is run before and after an Action is invoked

5) Value Stack: – The ValueStack permits the expression language to find property values across multiple objects. Thus Struts2 tags can access data from the action very easily.

6) Expression Language:- Struts 2 expression language is used for getting and setting properties of Java objects

7) Controller: – The controller receives all incoming requests. Its primary function is the mapping of a request URI to an action class selecting the proper application module.

8) Struts-config.xml file:- This file includes all of the routing and configuration information for the Struts application.

9) Action classes: – It’s the developer’s responsibility to create these classes. They act as bridges between user-invoked URIs and business services. Actions process a request and return an ActionForward object that identifies the next component to invoke. They’re part of the Controller layer, not the Model layer.

10) View resources:- The view resources includes Java Server Pages, HTML pages, JavaScript and Stylesheet files, Resource bundles, JavaBeans, and Struts JSP tags.

11) ActionForms: – These greatly simplify user form validation by capturing user data from the HTTP request. They act as a “firewall” between forms (Web pages) and the application (actions). These components allow the validation of user input before proceeding to an Action. If the input is invalid, a page with an error can be displayed.

12) Model componenets: – The Struts Framework has no built-in support for the Model layer. A strut supports any model components. Some model components are,

1) JavaBeans

2) EJB

3) CORBA

4) JDO

5) any other

Features of strut frameworks

1) Open source

2) Implements the JSP Model 2 Architecture

3) Stores application routing information and request mapping in a single core file, struts-config.xml

4) The Struts Framework, itself, only fills in the View and Controller layers. The Model layer is left to the developer

5) OGNL and ValueStack: – OGNL stands for Object-Graph Navigation Language and it is a powerful expression language that is used to reference and manipulate data on the ValueStack. OGNL provides a mechanism of data transfer and type conversion. OGNL expression language provides simplified syntax to reference java objects. OGNL is used to bind the java-side data properties to the string-based view layer. In Struts 2 the action resides on the ValueStack which is a part of the ActionContext. ActionContext is a global storage area that holds all the data associated with the processing of a request.

Comments

Popular posts from this blog

JDK 25: The new features in Java 25

 Java Development Kit (JDK) 25, scheduled for release in September 2025, is set to introduce several significant enhancements. Here's an overview of the notable features: 1. Stable Values API (Preview): This feature introduces stable values—objects holding immutable data treated as constants by the Java Virtual Machine (JVM). By allowing greater flexibility in initialization timing compared to final fields, stable values aim to improve application startup times. They enable performance optimizations akin to constant-folding, previously exclusive to JDK code, and ensure thread-safe, single-time initialization. This decouples the creation of stable values from their initialization without significant performance penalties.  2. Removal of 32-bit x86 Port: JDK 25 plans to eliminate both the source code and build support for the 32-bit x86 port, which was deprecated in JDK 24. Maintaining this port has become less beneficial, especially with the challenges in keeping it updated wit...

Java 24 Released: What's New and Why It Matters?

 Oracle has officially released Java 24 on March 18, 2025, bringing a host of new features aimed at improving developer productivity, security, and performance. This release includes over 20 enhancements, making Java even more powerful for modern application development. Let’s dive into the key features and improvements in Java 24 and understand why they matter. --- 1. AI and Machine Learning Support Java 24 introduces features designed to enhance AI-powered applications. Developers can now integrate AI models and perform AI inference more efficiently using built-in Java capabilities. Why It Matters? With AI becoming a crucial part of modern applications, Java 24 makes it easier to process and deploy AI models without relying heavily on third-party libraries. --- 2. Post-Quantum Cryptography To prepare for the future threats of quantum computing, Java 24 includes new cryptographic algorithms that protect against potential security breaches. Why It Matters? Quantum computers could p...

Hanumankind’s ‘Run It Up’: A New Wave in Indian Hip-Hop

 Indian rapper Hanumankind, born Sooraj Cherukat, has recently released a new single titled "Run It Up," produced by Kalmi. The official music video debuted last week and showcases Hanumankind's dynamic performance style.  Prior to this release, Hanumankind gained international recognition with his 2024 hit "Big Dawgs," also produced by Kalmi. The track's innovative music video, featuring Hanumankind performing within a "well of death" motordrome, contributed to its viral success.  "Run It Up" continues Hanumankind's exploration of blending traditional Indian musical elements with contemporary hip-hop beats. The track reflects his unique style, influenced by his upbringing in both Kerala, India, and Houston, Texas.  Fans and critics have praised "Run It Up" for its energetic rhythm and catchy hooks. Discussions on platforms like Reddit highlight the song's fusion of genres and its potential to further elevate Hanumankind...