If you're looking for Struts Interview Questions for Experienced or Freshers, you are at 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 2019 that helps you in cracking your interview & acquire dream career as Struts Developer.
Top 13 Struts Interview Questions
Q1): 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, ResourceBundles 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.
Q2): 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.
Q3): 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
Q4): How the flow of requests takes 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.
Q5): 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
Q6): 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.
Q7): 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 help of the configuration files in order to create the form of beans.
Q8): 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.
Q9): 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 customisation of 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!
Q10): 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 case of a framework.
** This will also give you the liberty to use Jakarta Packages, JavaBeans, XML, Java Servlets etc.
Q11): What is the ForwardAction used for?
Subscribe to our youtube channel to get new updates..!
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. The 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.
Q12): 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 Struts framework. The controller selects the actions for the requests that are received, then generates a result for the request or action and lastly executes the action.
Q13): 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.
Q14): How can you use the resource bundle.properties file for Struts Validation framework?
In order to define certain error messages resource bundle.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.
Q15): 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.
Q16): Describe the two types of Formbeans.
There are two different types of Formbeans:
** Request Scope: When the Scope type is request, the values of the formbeans are available with the current request.
** Session Scope: When the scope type is a session, the values of the formbeans are found for all the requests in the recent session.
Q17): How to migrate an application from “Strut 1” to “Strut 2”.
There are multiple steps for migration of an application from the 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
Q18): 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:
3. Velocity Templates
5. WML Files
Apart from this many other technologies can be also used, but these are the primary ones used for the view layers.
Q19): Explain the complete Struts Validator Framework.
The Struts Validator Framework helps us in validating 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.
Q20): 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 like execute method.
Q21): Describe the drawbacks in 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 case of struts framework.
Q22): What is meant by Custom Tags?
These are customised 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.
Q23): 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 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?
Upcoming Batches - Struts Training!
6:30 AM IST
6:30 AM IST
6:30 AM IST
7:00 AM IST
During the submission or fill-up of a form, is 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.
Q25): 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 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.
Q26): 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 of 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.
Q27): Name the different actions found in Struts.
The different actions found in Struts are:
Q28): 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.
Q29): Name the different libraries for Strut tags.
The different Strut tag libraries present are:
1. Bean Tags: This is used for accessing bean 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.
Q30): 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 are 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 case of Struts, the tags can be user-defined.