Open In App

Introduction and Working of Struts Web Framework

Last Updated : 21 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Struts is an open-source web application framework developed by Apache Software Foundation, it is used to create a web application based on servlet and JSP. It depends on the MVC (Model View Controller) framework. Struts are thoroughly useful in building J2EE (Java 2 Platform, Enterprise Edition) applications because struts take advantage of J2EE design patterns. Struts follows these J2EE design patterns including MVC and JSP custom tag libraries. In struts, the composite view manages the layout of its sub-views and can implement a template, making persistent look and feel easier to achieve and customize across the entire application. A composite view is made up by using other reusable sub-views such that a small change that happens in a sub-view is automatically updated in every composite view. Struts consist of a set of custom tag libraries. Struts also support utility classes.

The main purpose of the struts framework is to provision separation of concerns between the business logic and the presentation logic (view), making it easier to manage and develop large-scale web applications.

Features of Struts

Struts have the following features:

  • Struts encourages good design practices and modeling because the framework is designed with “time-proven” design patterns.
  • Struts is almost simple, so easy to learn and use.
  • It supports many convenient features such as input validation and internationalization.
  • It takes much of the complexity out as instead of building your own MVC framework, you can use struts.
  • Struts is very well integrated with J2EE.
  • Struts has large user community.
  • It is flexible and extensible; it is easy for the existing web applications to adapt the struts framework.
  • Struts provide good tag libraries.
  • It allows capturing input form data into JavaBean objects called Action forms.
  • It also hands over standard error handling both programmatically and declaratively.

Working of Struts:

Working Flow of Struts

Step-by-Step Implementation of Struts

Step 1: Initialization Phase

  • In initial phase, the controller rectifies a configuration file.
  • This configuration file is like the manual for initialization and is used to deploy the controller layer objects.

Step 2: Composition of Configuration file

  • Config file’s core is formed by all the objects defined inside it.
  • These objects include action mapping which plays in defining the behavior of application.
  • Furthermore, it also contains the definition of these action mappings.
  • Action mappings are the key aspects in instructing the servlet controllers for handling the HTTP Requests.

Step 3: Routing of HTTP Requests & process flow

  • Initially, the requests are directed towards the action and then JSP.
  • JSP does further processing and rendering the view page.

Step 4: Action object request handling

  • Action objects handle all the requests of client.
  • These objects have access to the servlet controller of our application, and they can execute specific actions defined inside controllers.

The action object can indirectly forward one or more shared objects, these shared objects can be JavaBeans, and are typically shared in shared context which is established using Java Servlets.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads