Struts Interview Questions

1Q) What is Struts?

Ans: The core of the Struts framework is a flexible control layer based on standard technologies like Java Servlets, JavaBeans, resource bundles, and XML, as well as various Jakarta Commons packages. Struts encourage application architectures based on the Model 2 approach, a variation of the classic Model-View-Controller (MVC) design paradigm.

Struts provide its own Controller component and integrate 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 help you create an extensible development environment for your application, based on published standards and proven design patterns.

2Q) What is the Jakarta Struts Framework?

Ans: Jakarta Struts is an 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 applications of any size. Struts framework makes it much easier to design scalable, reliable Web applications with Java.

3Q) What is Struts Validator Framework?

Ans: Struts Framework provides the functionality to validate the form data. It can be used to validate the data on the user's browser as well as on the server-side. Struts Framework emits the java scripts and it can be used to validate the form data on the client browser. Server-side validation of form can be accomplished by subclassing your From Bean with DynaValidatorForm class.

The Validator framework was developed by David Winterfeldt as a third-party add-on to Struts. Now the Validator framework is a part of the 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.

Interested in mastering Struts Training? Enroll now for a FREE demo on "Struts Training"

4Q) Give the Details of XML files used in Validator Framework?

Ans: 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 of specific validations. The validation.xml defines the validations applied to a form bean.

5Q) What are the classes used in Struts?

Ans: Struts Framework consists of the following classes:

Action Servlets: Used to control the response for each incoming request.

Action Class: Used to handle the request.

Action Form: It is a java bean, used to refer 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.

6Q) What design patterns are used in Struts?

Ans: There are following types of design patterns are used in Struts:

Service to Worker

Dispatcher View

Composite View (Struts Tiles)

Front Controller

View Helper

Synchronizer Token

7Q) What is the different actions available in Struts?

Ans: The different kinds of actions in Struts are:

ForwardAction

IncludeAction

DispatchAction

LookupDispatchAction

SwitchAction

8Q) What are the various Struts tag libraries?

Ans: The various Struts tag libraries are:

HTML Tags: used to create the struts input forms and GUI of the 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.

9Q) What are the loopholes of Struts?

Ans: The drawbacks of Struts are the following:

Absence of backward flow mechanism.

Only one single controller Servlets is used.

Bigger learning curve.

Worst documentation.

No exception present in this framework.

Less transparent.

A rigid approach.

With struts 1, embedding application into JSP can’t be prevented.

Non-XML compliance of JSP syntax.

10Q) What steps are required for an application migration from Struts1 to Struts2?

Ans: The following steps are required for Struts1 to Struts2 migration:

Move the Struts1 action form to Struts2 POJO.

Convert Struts1 configuration file (struts-config.xml) to Struts2 configuration file (struts.xml)

11Q) How properties of a form are validated in Struts?

Ans: For validation of populated properties, the validate() method of ActionForm class is used before handling the control of form bean to Action class.