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

Dealing with Passwords in Java Applications: 5 Best Practices You Should Follow

 In modern Java applications—whether core Java applications or enterprise-level web applications—working with passwords is inevitable. Passwords are sensitive pieces of information, just like Social Security Numbers (SSNs), and if you’re handling real human data in systems such as online banking or healthcare portals, it’s critical to implement best practices for dealing with passwords securely. Below, I’ll share five essential best practices that I’ve learned and recommend for managing passwords, particularly when you are handling authentication and authorization. While these tips are a good starting point, be sure to tailor them to your application’s requirements and security policies. 1) Use SSL/TLS to Transfer Username and Password When users send passwords over the network, it is crucial to use SSL/TLS to encrypt the communication. This ensures that sensitive information is protected from eavesdroppers. Tools like LDAP and Active Directory are commonly used for storing usern...

Understanding DeepSeek: A New Player in AI

DeepSeek is a Chinese artificial intelligence (AI) company founded in 2023, dedicated to advancing artificial general intelligence (AGI). Their flagship model, DeepSeek-R1, launched in January 2025, is an open-weight AI model designed to perform complex reasoning tasks, including solving scientific problems.  How DeepSeek Works DeepSeek-R1 operates as a reasoning model, capable of autonomous exploration and information synthesis. It can navigate the web, select pertinent information, and compile detailed reports, automating tasks typically handled by humans. This functionality positions DeepSeek-R1 as a versatile tool for various applications, from research to customer service.  DeepSeek's Impact on the AI Landscape DeepSeek's emergence has disrupted the AI sector, challenging established models like OpenAI's ChatGPT. Its open-weight approach and cost-effective development have made advanced AI capabilities more accessible. Chinese companies and government agencies have rap...

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...