Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

What Is Struts.devmode?

Answer»

The struts.devMode is used to make sure that framework is running in development mode or production mode by setting true or false. struts.devMode is set to false in production PHASE to reduce impact of performance. By default it is "false". 
It is used because of the following reasons:
Resource Reloading: Resource BUNDLE reload on every request
Modification: struts.xml can be MODIFIED without restarting or redeploying the APPLICATION
ERROR Handling: The error occurs in the application will be reported, as oppose to production mode.

The struts.devMode is used to make sure that framework is running in development mode or production mode by setting true or false. struts.devMode is set to false in production phase to reduce impact of performance. By default it is "false". 
It is used because of the following reasons:
Resource Reloading: Resource bundle reload on every request
Modification: struts.xml can be modified without restarting or redeploying the application
Error Handling: The error occurs in the application will be reported, as oppose to production mode.

2.

What Is Dispatchaction?

Answer»

1.The DispatchAction enable the programmer to combine together related function or class.
2.Using Dispatch ACTION programmer can combine the USER related action into a single UserAction. like add user, delete user and UPDATE user.
3.DispatchAction execute the action BASED on the PARAMETER value it receives from the user.

1.The DispatchAction enable the programmer to combine together related function or class.
2.Using Dispatch Action programmer can combine the user related action into a single UserAction. like add user, delete user and update user.
3.DispatchAction execute the action based on the parameter value it receives from the user.

3.

How Exceptions Are Handled In Struts Application?

Answer»

Exceptions are handled in struts by using any one of the following TWO ways:
Programmatically handling: In this EXCEPTION are handled by using try and catch BLOCK in program. Using this programmer can define how to handle the situation when exception arises.
Declarative handling: In this exception handling is done by using the XML FILE. Programmer defines the exception handling logic in the XML file. 
There are two ways of defining the exception handling logic in the XML file:
1.Global Action SPECIFIC Exception Handler Definition.
2.Local Action Specific Exception Handler Definition.

Exceptions are handled in struts by using any one of the following two ways:
Programmatically handling: In this exception are handled by using try and catch block in program. Using this programmer can define how to handle the situation when exception arises.
Declarative handling: In this exception handling is done by using the XML file. Programmer defines the exception handling logic in the XML file. 
There are two ways of defining the exception handling logic in the XML file:
1.Global Action Specific Exception Handler Definition.
2.Local Action Specific Exception Handler Definition.

4.

What Are The Different Kinds Of Actions In Struts?

Answer»

The DIFFERENT KINDS of ACTIONS in STRUTS are:
1.ForwardAction
2.IncludeAction
3.DispatchAction
4.LookupDispatchAction
5.SwitchAction

The different kinds of actions in Struts are:
1.ForwardAction
2.IncludeAction
3.DispatchAction
4.LookupDispatchAction
5.SwitchAction

5.

What Design Patterns Are Used In Struts?

Answer»

Struts is based on model 2 MVC (Model-View-Controller) ARCHITECTURE. Struts controller USES the command DESIGN pattern and the action classes use the adapter design pattern. The process() METHOD of the RequestProcessor uses the template method design pattern. Struts also implement the following J2EE design patterns.
1.Service to Worker
2.Dispatcher View
3.Composite View (Struts TILES)
4.Front Controller
5.View Helper
6.Synchronizer Token

 

Struts is based on model 2 MVC (Model-View-Controller) architecture. Struts controller uses the command design pattern and the action classes use the adapter design pattern. The process() method of the RequestProcessor uses the template method design pattern. Struts also implement the following J2EE design patterns.
1.Service to Worker
2.Dispatcher View
3.Composite View (Struts Tiles)
4.Front Controller
5.View Helper
6.Synchronizer Token

 

6.

When Should Be Opt For Struts Framework?

Answer»

Struts should be used when any or some of the following conditions are true:
1.A HIGHLY robust enterprise level APPLICATION development is required.
2.A reusable, highly configurable application is required.
3.A loosely coupled, MVC based application is required with clear segregation of DIFFERENT LAYERS.

 

Struts should be used when any or some of the following conditions are true:
1.A highly robust enterprise level application development is required.
2.A reusable, highly configurable application is required.
3.A loosely coupled, MVC based application is required with clear segregation of different layers.

 

7.

What Are The Core Classes Of Struts Framework?

Answer»

FOLLOWING are the CORE classes PROVIDED by Struts Framework:
1.Action Class
2.ActionForm Class
3.ActionMapping Class
4.ActionForward Class
5.ActionServlet Class

 

Following are the core classes provided by Struts Framework:
1.Action Class
2.ActionForm Class
3.ActionMapping Class
4.ActionForward Class
5.ActionServlet Class

 

8.

What Configuration Changes Are Required To Use Resource Files In Struts?

Answer»

RESOURCE files (.properties files) can be used in Struts by ADDING FOLLOWING CONFIGURATION entry in struts-config.xml file:
<message-resources PARAMETER=”com.login.struts.ApplicationResources”/>

 

Resource files (.properties files) can be used in Struts by adding following configuration entry in struts-config.xml file:
<message-resources parameter=”com.login.struts.ApplicationResources”/>

 

9.

Is Struts Thread Safe?

Answer»

Yes Struts are THREAD SAFE. In Struts, a NEW servlet object is not REQUIRED to handle each REQUEST; rather a new thread of action class object is used for each new request.

Yes Struts are thread safe. In Struts, a new servlet object is not required to handle each request; rather a new thread of action class object is used for each new request.

10.

Which Model Components Are Supported By Struts?

Answer»

STRUTS support all TYPES of models including Java beans, EJB, CORBA. However, Struts doesn’t have any in-built support for any specific model and it’s the DEVELOPER’s CHOICE to opt for any model.

Struts support all types of models including Java beans, EJB, CORBA. However, Struts doesn’t have any in-built support for any specific model and it’s the developer’s choice to opt for any model.

11.

How Many Servlet Controllers Are Used In A Struts Application?

Answer»

STRUTS framework WORKS on the concept of CENTRALIZED control APPROACH and the WHOLE application is controlled by a single servlet controller. Hence, we require only one servlet controller in a servlet application.

Struts framework works on the concept of centralized control approach and the whole application is controlled by a single servlet controller. Hence, we require only one servlet controller in a servlet application.

12.

What’s The Use Of Resourcebundle.properties File In Struts Validation Framework?

Answer»

resourcebundle.properties file is used to define specific error messages in key value pairs for any possible errors that MAY OCCUR in the code.
This APPROACH helps to keep the code CLEAN as developer doesn’t need to EMBED all error messages inside code.

resourcebundle.properties file is used to define specific error messages in key value pairs for any possible errors that may occur in the code.
This approach helps to keep the code clean as developer doesn’t need to embed all error messages inside code.

13.

What Are Disadvantages Of Struts?

Answer»

Although Struts have large number of advantages associated, it also requires bigger learning curve and also reduces TRANSPARENCY in the development process.
Struts also lack PROPER DOCUMENTATION and for many of its components, users are unable to get proper online RESOURCES for help.

Although Struts have large number of advantages associated, it also requires bigger learning curve and also reduces transparency in the development process.
Struts also lack proper documentation and for many of its components, users are unable to get proper online resources for help.

14.

How Properties Of A Form Are Validated In Struts?

Answer»

For validation of populated PROPERTIES, VALIDATE() method of ACTIONFORM class is used before handling the control of formbean to ACTION class.

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

15.

Why Actionservlet Is Singleton In Struts?

Answer»

In Struts FRAMEWORK, actionServlet acts as a CONTROLLER and all the requests made by users are controlled by this controller. ActionServlet is based onsingleton design patter as only one object needs to be CREATED for this controller CLASS. Multiple THREADS are created later for each user request.

In Struts framework, actionServlet acts as a controller and all the requests made by users are controlled by this controller. ActionServlet is based onsingleton design patter as only one object needs to be created for this controller class. Multiple threads are created later for each user request.

16.

What Are The Benefits Of Struts Framework?

Answer»

Struts is based on MVC and hence there is a good separation of different layers in Struts which makes Struts APPLICATIONS DEVELOPMENT and customization EASY. Use of different configuration files makes Struts applications EASILY configurable. ALSO, Struts is open source and hence, cost effective.

Struts is based on MVC and hence there is a good separation of different layers in Struts which makes Struts applications development and customization easy. Use of different configuration files makes Struts applications easily configurable. Also, Struts is open source and hence, cost effective.

17.

What Is Actionmapping?

Answer»

Action mapping contains all the deployment information for a particular Action BEAN. This class is to DETERMINE where the RESULTS of the Action will be sent once its processing is COMPLETE.

Action mapping contains all the deployment information for a particular Action bean. This class is to determine where the results of the Action will be sent once its processing is complete.

18.

What’s The Significance Of Logic Tags In Struts?

Answer»

Use of logic TAGS in Struts helps in writing a clean and efficient code at presentation LAYER without use of SCRIPTLETS

Use of logic tags in Struts helps in writing a clean and efficient code at presentation layer without use of scriptlets. 

19.

What’s The Use Of Struts.xml Configuration File?

Answer»

Struts.xml file is one the KEY configuration files of Struts FRAMEWORK which is used to DEFINE mapping between URL and action. When a USER’s request is received by the controller, controller uses mapping information from this file to SELECT appropriate action class.

Struts.xml file is one the key configuration files of Struts framework which is used to define mapping between URL and action. When a user’s request is received by the controller, controller uses mapping information from this file to select appropriate action class.

20.

What’s The Difference Between Validation.xml And Validator-rules.xml Files In Struts Validation Framework?

Answer»

In Validation.xml, we DEFINE validation RULES for any SPECIFIC Java bean while in validator-rules.xml file, standard and generic validation rules are DEFINED.

In Validation.xml, we define validation rules for any specific Java bean while in validator-rules.xml file, standard and generic validation rules are defined.

21.

Which Configuration File Is Used For Storing Jsp Configuration Information In Struts?

Answer»

For JSP CONFIGURATION DETAILS, Web.xml FILE is USED.

For JSP configuration details, Web.xml file is used.

22.

In Struts, How Can We Access Java Beans And Their Properties?

Answer»

Bean TAG Library is a Struts library which can be USED for ACCESSING Java BEANS.

Bean Tag Library is a Struts library which can be used for accessing Java beans.

23.

How Duplicate Form Submission Can Be Controlled In Struts?

Answer»

In Struts, ACTION class provides two IMPORTANT methods which can be used to avoid duplicate form submissions.
saveToken() method of action class generates a UNIQUE token and saves it in the user’s session.isTokenValid() method is used then used to check UNIQUENESS of TOKENS.

In Struts, action class provides two important methods which can be used to avoid duplicate form submissions.
saveToken() method of action class generates a unique token and saves it in the user’s session.isTokenValid() method is used then used to check uniqueness of tokens.

24.

What Are The Steps Of Struts Installation?

Answer»

In order to use STRUTS framework, we only need to add Struts.Jar file in our development environment. Once jar file is available in the CLASSPATH, we can use the framework and DEVELOP Strut BASED APPLICATIONS.

In order to use Struts framework, we only need to add Struts.Jar file in our development environment. Once jar file is available in the CLASSPATH, we can use the framework and develop Strut based applications.

25.

What’s The Role Of Action Class In Struts?

Answer»

In Struts, Action Class acts as a CONTROLLER and performs following KEY tasks:
1.After receiving user request, it PROCESSES the user’s request.
2.Uses appropriate model and pulls data from model (if required).
3.Selects proper view to show the RESPONSE to the user.

In Struts, Action Class acts as a controller and performs following key tasks:
1.After receiving user request, it processes the user’s request.
2.Uses appropriate model and pulls data from model (if required).
3.Selects proper view to show the response to the user.

26.

Which File Is Used By Controller To Get Mapping Information For Request Routing?

Answer»

Controller uses a configuration file “struts-config.xml file to get all mapping information to decide which ACTION to USE for routing of user’s request.It WORK as the ROUTER in the network and process and MAP the request to the associated action or resource.

Controller uses a configuration file “struts-config.xml file to get all mapping information to decide which action to use for routing of user’s request.It work as the router in the network and process and map the request to the associated action or resource.

27.

What Is The Advantage Of Having A Pojo Class As An Action?

Answer»

The POJO class is light WEIGHT and EASY to test with frameworks like Junit. MOREOVER, there is no need to create separate ActionForms as in struts one to HOLD the values from the source WEB page. It is done by a single POJO class in struts 2.

The POJO class is light weight and easy to test with frameworks like Junit. Moreover, there is no need to create separate ActionForms as in struts one to hold the values from the source web page. It is done by a single POJO class in struts 2.

28.

What Are The Components Of Struts Framework?

Answer»

Struts framework is composed of following components:
1. Based on the Model-View-Controller (MVC) design paradigm, distinctly separating all three levels:
Model: application state
View: presentation of data (JSP, HTML)
Controller: routing of the application flow
2. A request handler provided by the application developer that is used to mapped to a particular URI.
3. A response handler which is used to TRANSFER the control to another RESOURCE which will be RESPONSIBLE for completing the response.
4. A tag library which HELPS developers to create the interactive form based applications with server pages.
5. Java Servlets
6. JSP (Java Server Pages)
7. Custom Tags
8. MESSAGE Resources

Struts framework is composed of following components:
1. Based on the Model-View-Controller (MVC) design paradigm, distinctly separating all three levels:
Model: application state
View: presentation of data (JSP, HTML)
Controller: routing of the application flow
2. A request handler provided by the application developer that is used to mapped to a particular URI.
3. A response handler which is used to transfer the control to another resource which will be responsible for completing the response.
4. A tag library which helps developers to create the interactive form based applications with server pages.
5. Java Servlets
6. JSP (Java Server Pages)
7. Custom Tags
8. Message Resources