What is Struts?
The core of the Struts framework is a flexible control layer based on standard technologies like Java Servlets, JavaBeans, ResourceBundles, and XML, as well as various Jakarta Commons packages. Struts encourages application architectures based on the Model 2 approach, a variation of the classic Model-View-Controller (MVC) design paradigm.
Struts provides its own Controller component and integrates with other technologies to provide the Model and the View. For the Model, Struts can interact with standard data access technologies, like JDBC and EJB, as well as most any third-party packages, like Hibernate, iBATIS, or Object Relational Bridge. For the View, Struts works well with JavaServer Pages, including JSTL and JSF, as well as Velocity Templates, XSLT, and other presentation systems.
The Struts framework provides the invisible underpinnings every professional web application needs to survive. Struts helps you create an extensible development environment for your application, based on published standards and proven design patterns.
What is Jakarta Struts Framework?
Jakarta Struts is open source implementation of MVC (Model-View-Controller) pattern for the development of web based applications. Jakarta Struts is robust architecture and can be used for the development of application of any size. Struts framework makes it much easier to design scalable, reliable Web applications with Java.
What is Struts Validator Framework?
Struts Framework provides the functionality to validate the form data. It can be use to validate the data on the users browser as well as on the server side. Struts Framework emits the java scripts and it can be used validate the form data on the client browser. Server side validation of form can be accomplished by sub classing your From Bean with DynaValidatorForm class.
The Validator framework was developed by David Winterfeldt as third-party add-on to Struts. Now the Validator framework is a part of Jakarta Commons project and it can be used with or without Struts. The Validator framework comes integrated with the Struts Framework and can be used without doing any extra settings.
Give the Details of XML files used in Validator Framework?
The Validator Framework uses two XML configuration files validator-rules.xml and validation.xml. The validator-rules.xml defines the standard validation routines, these are reusable and used in validation.xml. to define the form specific validations. The validation.xml defines the validations applied to a form bean.
What are the classes used in Struts?
Struts Framework consists of following classes:
Action Servlets: Used to control the response for each incoming request.
Action Class: Used to handle the request.
Action Form: It is java bean, used to referred to forms and associated with action mapping.
Action Mapping: Used for mapping between object and action.
Action Forward: Used to forward the result from controller to destination.
What design patterns are used in Struts?
There are following types of design patterns are used in Struts:
Service to Worker
Composite View (Struts Tiles)
What is the different actions available in Struts?
The different kinds of actions in Struts are:
What are the various Struts tag libraries?
The various Struts tag libraries are:
HTML Tags: used to create the struts input forms and GUI of web page.
Bean Tags: used to access bean and their properties.
Logic Tags: used to perform the logical operation like comparison.
Template Tags: used to changes the layout and view.
Nested Tags: used to perform the nested functionality.
Tiles Tags: used to manages the tiles of the application.
What are the loop holes of Struts?
The drawbacks of Struts are following:
Absence of backward flow mechanism.
Only one single controller Servlets is used.
Bigger learning curve.
No exception present in this framework.
With struts 1, embedding application into JSP can’t be prevented.
Non-XML compliance of JSP syntax.
What steps are required to for an application migration from Struts1 to Struts2?
Following Steps are required for Struts1 to Struts2 migration:
Move Struts1 actionForm to Struts2 POJO.
Convert Struts1 configuration file (struts-config.xml) to Struts2 configuration file (struts.xml)
How properties of a form are validated in Struts?
For validation of populated properties, validate() method of ActionForm class is used before handling the control of formbean to Action class.
What’s the flow of requests in Struts based applications?
Struts based applications use MVC design pattern. The flow of requests is as follows:
User interacts with View by clicking any link or by submitting any form.
Upon user’s interaction, the request is passed towards the controller.
Controller is responsible for passing the request to appropriate action.
Action is responsible for calling a function in Model which has all business logic implemented.
Response from the model layer is received back by the action which then passes it towards the view where user is able to see the response.
What’s the role of Action Class in Struts?
In Struts, Action Class acts as a controller and performs following key tasks:
After receiving user request, it processes the user’s request.
Uses appropriate model and pulls data from model (if required).
Selects proper view to show the response to the user.