Struts interview question and anwers[Freshers]/Struts Interview Questions and Answers for Freshers & Experienced

Where is the Plug-in tag found in Struts2? What is the function of the Plug-in tag?

Plug-in tag is found in the struct-config.xml and is used to tell the user where the properties file that has all the prompt and error message is found.

Posted Date:- 2021-09-14 05:16:31

Mark the differences between HTML tags and Strut-specific HTML Tags.

The differences between both are:
1. The nature of HTML tags is Static whereas the nature of Struts-specific HTML tags is dynamic.
2. HTML is integrated into Struts but Struts have their own tag libraries.
3. The tags for HTML cannot be user-defined but in the case of Struts, the tags can be user-defined.

Posted Date:- 2021-09-14 05:15:40

What is meant by LookupDispatchAction?

This is a subclass under the DispatchAction class. This is required for calling the actual methods. For using the LookupDispatchAction, we need a certain set of rules and methods. This controls the forward mechanism by sending the request to the proper resource.

Posted Date:- 2021-09-14 05:14:52

Name the different actions found in Struts.

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

Posted Date:- 2021-09-14 05:14:08

How can you show validation errors on the JSP page?

These are the errors that appear when a client or user enters wrong or invalid data for filling up the application. At that moment, for validation, the method Validator() is used which works for the validation on both sides. In order to display the errors on the JSP page, the syntax code is.

Posted Date:- 2021-09-14 05:13:23

Mention the steps for combining Velocity templates and Struts.

In order to combine Velocity templates and Struts, follow the steps:
1. First, you have to set the classpath into Velocity JARs.
2. Then you need to make the web.xml for identifying the Velocity servlet.
3. In the WEB-INF directory, you have to choose velocity toolbox.xml
4. In order to point the view of struts-config from JSPs to velocity templates, you need modifications.
5. For every page that needs to be rendered create the velocity template

Posted Date:- 2021-09-14 05:12:39

What is meant by Action Errors?

During the submission or fill-up of a form, if a client or user makes a mistake in the data for the application that is known as Action Error. The client or user is solely responsible for them. They should be checked as early as possible. If they are not detected fast, they will waste server time and have a bad effect on the quality of codes.

Posted Date:- 2021-09-14 05:11:56

Describe the drawbacks of the Struts framework.

The different drawbacks in Struts are:
>> There is an absence of the flow mechanism in the backward direction.
>> This uses only one controller servlet.
>> There is no exception found in the framework.
>> The Struts Framework is not very transparent.
>> The documentation is very bad in the case of the struts framework.

Posted Date:- 2021-09-14 05:11:15

Name the different technologies for the View Layer.

There are many different technologies that can be used in the view layer. Some of them are:
1. JSP
3. Velocity Templates
5. WML Files
6. Servlets
Apart from this many other technologies can be also used, but these are the primary ones used for the view layers.

Posted Date:- 2021-09-14 05:10:42

Write the syntax to display the output page using XML in Struts2?

Here in Struts2, a user can declare the XML file as shown below:

<actionname="output “class="com.softwaretestinghelp.actionname">
<result name="SUCCESS">output.jsp</result>
<result name="ERROR">error.jsp</result>

Posted Date:- 2021-09-14 05:10:06

How are ValueStack and OGNL linked?

OGNL is a library through which the ValueStack data or values are manipulated whereas ValueStack is a stack where all values and data related to actions are stored.

Posted Date:- 2021-09-14 05:09:25

Are Struts2 Interceptors Synchronized?

As Struts2 interceptors are singleton classes and as a new thread is created to handle the request, it is not synchronized and we need to implement them carefully to avoid any issues with the shared data.

Posted Date:- 2021-09-14 05:08:54

Is Struts2 Action Synchronized?

Yes, Struts2 Actions are synchronized as an object is invoked to handle any new incoming request.

Posted Date:- 2021-09-14 05:08:20

What is the functionality of the Token Interceptor in Struts2?

The major problem with web applications is the double form submission that results in charging double amounts from the user and storing double values in the database. We can use a token interceptor to solve the double form submission problem. This interceptor is defined in the struts-default package.

Posted Date:- 2021-09-14 05:07:47

How can we create Custom Interceptor?

We can create the custom interceptor by implementing the Interceptor interface in a class and overriding its three life cycle method i.e. init (), Destroy (), Intercept (). It can also be created by defining the entry of the interceptor in the struts.xml file.

Posted Date:- 2021-09-14 05:07:12

What are the Core Components of Struts2?

The core components of Struts2 are as follows:

1. Interceptors
2. Value Stack
3. Action Context
5. ActionInvocation

Posted Date:- 2021-09-14 05:06:28

What do you mean by Internationalization? Why do we need it?

Internationalization (i18n) is the interceptor that is used for planning and implementing products and services so that they can be easily adapted to specific local languages and cultures i.e. a process called localization.

It handles setting locale for the action. It can be used if the user wants to set his/her locale and get data according to the locale provided.

Posted Date:- 2021-09-14 05:04:57

What is the default result type in Struts2?

The default result type in struts2 is the dispatcher. It is used to dispatch the JSP pages.

Posted Date:- 2021-09-14 05:04:24

What are the different types of tags in Struts2?

The various types of tags in Struts2 are as follows:

>> Control Tag (If Else tag, Iterator Tag, Merge Tag, Append Tag, Generator Tag, etc.)
>> Data Tag (Action tag, Include Tag, Bean Tag, Date Tag, Param Tag, Property Tag, Push Tag, Set Tag, Text Tag, etc.)
>> Form Tag (All the simple UI Tags.)
>> Ajax Tag

Posted Date:- 2021-09-14 05:03:34

How can we Handle Exceptions in Struts?

In Struts, exceptions can be handled in two ways as shown below.

Programmatic Exception Handling: In this, we can use Try {} Catch {} block to handle the exception.
Declarative Exception Handling: Here, we can define the global exception handling tags in struts-config.xml or define exception handling tags within tags.

Posted Date:- 2021-09-14 05:02:46

What are the types of constants present in the Action Interface?

There are five types of constants provided by the Action Interface.

They are:

1. Login
2. Input
3. Success
4. Error
5. None

Posted Date:- 2021-09-14 05:02:13

What is the use of OGNL?

Object Graph Navigation Language (OGNL) is a strong expression language. It helps to simplify the accessibility of data stored in the ActionContext. OGNL supports interacting with collections i.e. Map, List, and Set.

The struts framework helps to set the ValueStack as the root object of OGNL. The action object is pushed into the ValueStack and we can directly access the action property.

Posted Date:- 2021-09-14 05:01:25

What is the use of ActionInvocation?

The ActionInvocation is used to represent the action’s execution state. It holds the action and the interceptor object.

Posted Date:- 2021-09-14 05:00:51

How to migrate an application from “Strut 1” to “Strut 2”.

There are multiple steps for the migration of an application from strut 1 to strut 2. The steps are:
Firstly you have to move the Strut 1 Action form.
After moving it, you have to place it in Strut 2 POJO.
Then you have to convert the configuration file of struts 1 i.e. struts-config.xml into the configuration file of struts 2 i.e. struts.xml

Posted Date:- 2021-09-14 05:00:27

Describe the two types of Form beans.

There are two different types of Formbeans:
** Request Scope: When the Scope type is request, the values of the form beans are available with the current request.
** Session Scope: When the scope type is a session, the values of the form beans are found for all the requests in the recent session.

Posted Date:- 2021-09-14 05:00:03

What is the difference between Apache Struts and Jakarta Struts?

If you are asked about this, then remember this is a trick question. There is absolutely no difference between the two, they are the same.

Posted Date:- 2021-09-14 04:59:33

How can you use the resource bundle.Do properties file for Struts Validation framework?

In order to define certain error messages resource bundle.the properties file is required. It is done in input value pairs. This is done for checking all the errors in the whole coding that may have slipped. This way it is ensured that the code is clean since the developer no longer has to worry about the embedded error messages in the code.

Posted Date:- 2021-09-14 04:59:09

What do you mean by Value Stack?

A Value Stack can be explained as a stack that contains requirement specific objects. The action stays at the top of the stack while executing.

The objects are then placed in Value Stack and the user can perform SQL operations on it.

The various methods of Value Stack are as follows:

FindString (): Used to find the string from the given expression.
FindValue (): Used to find value from the given expression.
Peek (): It gives the object located at the top of the stack.
Pop (): It gives the object located at the top of the stack and removes it.
Push (): It pushes the object to the top of the stack.

Posted Date:- 2021-09-14 04:58:16

What is the use of Validate () and Reset () methods in Struts?

Validate () method is used to validate the properties after they have been populated and it is called before the Form Bean is passed to the action. It returns a collection of action errors.

Syntax: Public ActionErrors Validate (ActionMapping mapping, HttpServletRequest request)

Reset () method is used to reset all the ActionForm’s data before the new values are being set. It is called by the struts framework with each request that uses a defined action form.

Syntax: public void reset ((ActionMapping mapping, HttpServletRequest request)

Posted Date:- 2021-09-14 04:57:17

What is the ForwardAction used for?

When we want to combine an existing application with struts, we need to use the ForwardAction. ForwardAction is also used whenever one wants to transfer the complete control from one place to another, say, JSP to a local server. ForwardAction is also used when one wants to obtain the benefits of the functionality of struts after the integration with Struts. In this case, Servlets are never written again. Another use of ForwardAction is when a request is forwarded to other resources.

Posted Date:- 2021-09-14 04:56:50

Describe the benefits of the Struts framework.

The Struts framework is completely working on MVC architecture. This ensures that the different layers of Struts are separated properly which further ensures the development and the customization of the application easy. Because files of different configurations are used thus the configuration of applications also becomes easy. Struts framework is also open-source software and thus the best part, it is cost-effective!

Posted Date:- 2021-09-14 04:56:28

Name all the core classes in Struts Framework.

The Core classes in Struts Framework are:
1. Action Servlet: This is the most important part of the whole application since it works as the backbone of the framework.
2. ActionForm: This is a Java Bean and it is used for referring to forms.
3. Action Class: This is used for handling all the requests.
4. Action Mapping: This is used for the process of mapping within the object and the action.
5. ActionForward: This forwards the results from the controller to the destination.

Posted Date:- 2021-09-14 04:56:03

What are the two different validations that the Validator Framework supports?

For the purpose of Validation of form data, the Validator framework is used. The two different validations are:
1. Client-Side Validation
2. Server-Side Validation

Posted Date:- 2021-09-14 04:55:37

What’s DynaActionForm?

DynaActionForm is a special type of actionForm class (sub-class of ActionForm Class) that’s used for dynamically creating form beans. It uses configuration files for form bean creation.

Posted Date:- 2021-09-14 04:55:11

How can we display all validation errors to user on JSP page?

To display all validation errors based on the validation rules defined in validation.xml file, we use <html:errors /> tag in our JSP file.

Posted Date:- 2021-09-14 04:54:18

What’s the difference between validation.xml and validator-rules.xml files in Struts Validation framework?

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.

Posted Date:- 2021-09-14 04:53:56

Which configuration file is used for storing JSP configuration information in Struts?

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

Posted Date:- 2021-09-14 04:53:27

How the flow of requests take place in Struts Application?

Struts Applications use the MVC designs and the flow of request happens in this way:
** The user interacts with the view after clicking on a link or after they submit a form.
** After the interaction takes place, the request is forwarded to the controller.
** The controller is the person held responsible for forwarding the request for better action.
** Action class decides the function which further works for the business logic that is to be implemented.
** The last step is the response, it occurs after the model layer sends it and it is viewed on the screen by the user.

Posted Date:- 2021-09-14 04:52:54

What is meant by Action Class?

In a Struts application, the action class handles the requests. The action class is the interface between the request (HTTP) and the logic used for developing the application. The RequestProcessor in the action class works as the controller which chooses the proper action for the requests that are received.

Posted Date:- 2021-09-14 04:52:31

In Struts, how can we access Java beans and their properties?

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

Posted Date:- 2021-09-14 04:51:59

What is the function of the Struts.xml File in Struts?

In the struts.xml file, the user can define all the mapping to actions so that a particular action is called when a particular operation is performed. It is also called as the configuration file and is present under the WEB-INF/classes folder.

Posted Date:- 2021-09-14 04:51:39

What are the Life Cycle methods of the Interceptor?

There are three life cycle methods of the Interceptor as mentioned below.

1. init () method
2. intercept () method
3. destroy () method

Posted Date:- 2021-09-14 04:51:13

How duplicate form submission can be controlled in Struts?

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.

Posted Date:- 2021-09-14 04:50:31

What are the steps of Struts Installation?

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.

Posted Date:- 2021-09-14 04:50:07

What are Interceptors?

Interceptors are the object that provides the pre-processing logic before action is called or provides a post-processing logic after the action is called. Interceptors can be used to perform various operations such as Validations, Exception Handling, File Uploading, Displaying intermediate results, etc.

Posted Date:- 2021-09-14 04:49:51

What is MVC?

MVC stands for Model, View, and Controller and is called the Software Design Pattern for developing web applications.

Model: Model is responsible for maintaining the State of Data and Business logic of the application.
View: View is responsible to show all data to use i.e. it shows the presentation.
Controller: Controller acts as an interface between View and Model. It intercepts all the requests i.e. receives input and commands to Model/View to change accordingly.

Posted Date:- 2021-09-14 04:49:36

What are the new features of Struts2?

The prominent features of Struts2 are as follows.

<> In Struts2, the Action class is POJO. We don’t need to inherit any class or implement any interface.
<> Struts2 has JSP, Free marker, and Valocity for the view component.
<> In Struts2, Front Controller is StrutsPrepareAndExecuteFilter.
<> In Struts2, the configuration file name must be struts.xml and should be placed inside the classes directory.
<> Struts2 uses the concept of Interceptors while processing the request.

Posted Date:- 2021-09-14 04:48:52

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.

Posted Date:- 2021-09-14 04:47:28

Which file is used by controller to get mapping information for request routing?

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.

Posted Date:- 2021-09-14 04:46:05

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.

Posted Date:- 2021-09-14 04:45:44

Why do we use Struts?

As Struts is based on MVC architecture i.e. Model, View, Controller, it separates Business Logic, Design & Controller, as a result of which it makes the code more simple, maintainable and readable.

Posted Date:- 2021-09-14 04:43:38

What is Struts Framework? What are its Components?

Struts is a type of Web Application Development Framework that provides a suitable platform for developing web applications. Struts include Servlets, JSP, Custom tags and Message resources into a unified framework.

Posted Date:- 2021-09-14 04:43:10

R4R Team
R4R provides Struts Freshers questions and answers (Struts Interview Questions and Answers) .The questions on website is done by expert team! Mock Tests and Practice Papers for prepare yourself.. Mock Tests, Practice Papers,Struts interview question and anwers[Freshers],Struts Freshers & Experienced Interview Questions and Answers,Struts Objetive choice questions and answers,Struts Multiple choice questions and answers,Struts objective, Struts questions , Struts answers,Struts MCQs questions and answers R4r provides Python,General knowledge(GK),Computer,PHP,SQL,Java,JSP,Android,CSS,Hibernate,Servlets,Spring etc Interview tips for Freshers and Experienced for Struts fresher interview questions ,Struts Experienced interview questions,Struts fresher interview questions and answers ,Struts Experienced interview questions and answers,tricky Struts queries for interview pdf,complex Struts for practice with answers,Struts for practice with answers You can search job and get offer latters by studing .learn in easy ways .