Struts Interview Questions

If you're looking for Struts Interview Questions for Experienced or Freshers, you are in right place. There are a lot of opportunities from many reputed companies in the world. According to research Struts has a market share of about 1%. So, You still have the opportunity to move ahead in your career in Document Object Model in Apache Struts. Mindmajix offers Advanced Struts Interview Questions 2024 that helps you in cracking your interview & acquire a dream career as a Struts Developer.

Top 10 Struts Interview Questions and Answers

1. What do you mean by the term Struts?

2. What is meant by Action Class?

3. Describe the different components of Struts.

4. How the flow of requests takes place in the Struts Application?

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

6. How to control the submission of duplicate forms in Struts?

7. What do you mean by DynaActionForm?

8. Name all the core classes in Struts Framework.

9. Describe the benefits of the Struts framework.

10. Why do we need struts?


If you want to enrich your career and become a professional in Struts, then enroll in "Struts Training" - This course will help you to achieve excellence in this domain.

Best Struts Interview Questions and Answers

1) What do you mean by the term Struts?

Struts can be defined as open-source software that can be used for developing web pages that are java based. Struts use different components and packages like XML, Jakarta Packages, JavaBeans, resource bundles, etc. Struts use the Model View Controller (MVC) architecture as support. In this case by Model, it is being talked about a business or a database, with View it is being referred to a page design code and lastly the controller means the navigational code. 

2) 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. 

3) Describe the different components of Struts.

The struts framework has the following components:
1. Java Servlets
2. Custom Tags
3. JSP (Java Server Pages)
4. Message Resources

4) 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.

5) 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

Blog post image

Subscribe to explore the latest tech updates, career transformation tips, and much more.

6) How to control the submission of duplicate forms in Struts?

In Struts, two different methods are used in order to stop the submission of duplicate forms. These methods are provided by the action class: 
>> saveToken() is the first method that is provided by the action class for generating a unique token that is further saved under the user’s session. 
>> isTokenValid() is another method that is used while one wants to check the uniqueness of the tokens. 

7) What do you mean by DynaActionForm?

DynaActionForm is a sub-class of the ActionForm class which is used for the creation of form beans dynamically. It takes the help of the configuration files in order to create the form of beans. 

8) 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. 

9) 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! 

10) Why do we need struts?

The reasons for which we need Struts are:
** This helps the programmers and developers in the creation of the application and also the maintenance. 
** This uses the Model View Controller (MVC) architecture, which is a big plus point in the case of a framework. 
** This will also give you the liberty to use Jakarta Packages, JavaBeans, XML, Java Servlets, etc. 

11) 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. 

12) What are the uses of ActionClass?

The action class included in the Strut application is responsible for handling requests. The action class acts as the medium or interface within the HTTP requests that are coming and the business logic that is used for developing the application. Request Processor in the Action Class acts as the major controller and is the single controller of the Struts framework. The controller selects the actions for the requests that are received, then generates a result for the requestor action, and lastly executes the action. 

13) When should you use Struts Framework?

You should opt for the struts framework when the given conditions are fulfilled: 
>> Firstly an application development of a very high-level robust enterprise is necessary.
>> An application is required that can be reused and is configurable completely or to a certain level. 
>> An application is required which is MVC based, is coupled very loosely, and also has clear segregation within the different layers. 

14) 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. 

15) 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. 

16) 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. 

17) 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

18) 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. 

19) Explain the complete Struts Validator Framework.

The Struts Validator Framework helps us invalidating the data for both the client’s side and the server’s side. If some data is missing while validation or some data is not validated, the programmer is free to add their own concept or logic for validation. This validation logic is further bound with the framework. The validation framework has two different XML files- Validator-Rules.xml file and Validation.xml file.

20) What do you mean by Dispatch action and how do we use it?

The Dispatch action is responsible for allowing the programmer for combining two related functions or classes. With the help of this action, the programmer can also combine two similar actions and make one major or User action. It can be used for creating a class for extending the action. It can also be used for the addition of a method with a similar signature to like execute method. 

Q21) 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. 

22) What is meant by Custom Tags?

These are customized tags by the users that they can use in the application depending on their needs. If a JSP page with custom tags or user-defined tags is translated then the custom also gets translated. Because the tags are reusable, they also help in better development. 

23) State the differences between Struts 1 and Struts 2.

The main differences between the two Struts are:
** The controller used by both Struts are different, ActionServlet is used by Strut 1 and Filter by Strut 2. 
** For mapping the forms (JSP), Struts1 uses ActionForm. However, in the case of Struts 2, no such ActionForm is available. 
** In the case of Strut 1 for validation of data, Validation () the method is used but for Strut 2 it is done by the Validation framework. 

Q24) 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. 

25) 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. 

26) 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. 

27) Name the different actions found in Struts.

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

28) 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. 

29) Name the different libraries for Strut tags.

The different Strut tag libraries present are: 
1. Bean Tags: This is used for accessing beans and also their properties. 
2. HTML Tags: This is necessary for the creation of struts forms and GUI of the web pages. 
3. Logic Tags: This is used for performing all the logical operations.
4. Nested Tags: This is used for performing all the nested functions. 

30) 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.

→ Explore Struts Sample Resumes Download & Edit, Get Noticed by Top Employers!


Course Schedule
Struts TrainingJul 13 to Jul 28View Details
Struts TrainingJul 16 to Jul 31View Details
Struts TrainingJul 20 to Aug 04View Details
Struts TrainingJul 23 to Aug 07View Details
Last updated: 02 Jan 2024
About Author

Ravindra Savaram is a Technical Lead at His passion lies in writing articles on the most popular IT platforms including Machine learning, DevOps, Data Science, Artificial Intelligence, RPA, Deep Learning, and so on. You can stay up to date on all these technologies by following him on LinkedIn and Twitter.

read less