Home Interview Questions and Answers Struts2 Interview Questions and Answers For Graduates Part-1

struts 21.What is Struts2?
Struts2 is popular and mature web application framework based on the MVC design pattern. Struts2 is not just the next version of Struts 1, but it is a complete rewrite of the Struts architecture.

2.Name some of the features of Struts2.
Here are some of the great features that may force you to consider Struts2 −

POJO forms and POJO actions − Struts2 has done away with the Action Forms that were an integral part of the Struts framework. With Struts2, you can use any POJO to receive the form input. Similarly, you can now see any POJO as an Action class.

Tag support − Struts2 has improved the form tags and the new tags allow the developers to write less code.

AJAX support − Struts2 has recognised the take over by Web2.0 technologies, and has integrated AJAX support into the product by creating AJAX tags, that function very similar to the standard Struts2 tags.

Easy Integration − Integration with other frameworks like Spring, Tiles and SiteMesh is now easier with a variety of integration available with Struts2.

Template Support − Support for generating views using templates.

Plugin Support − The core Struts2 behaviour can be enhanced and augmented by the use of plugins. A number of plugins are available for Struts2.

3.What are the core components of a Struct2 based application?
The Model-View-Controller pattern in Struts2 is realized with following five core components −

Actions

Interceptors

Value Stack / OGNL

Results / Result types

View technologies

4.Explain the life cycle of a request in Struct2 application.
Following is the life cycle of a request in Struct2 application −

User sends a request to the server for requesting for some resource (i.e pages).

The FilterDispatcher looks at the request and then determines the appropriate Action.

Configured interceptors functionalities applies such as validation, file upload etc.

Selected action is executed to perform the requested operation.

Again, configured interceptors are applied to do any post-processing if required.

Finally the result is prepared by the view and returns the result to the user.

5.What is the purpose of struts.xml in Struct2?
The struts.xml file contains the configuration information that you will be modifying as actions are developed. This file can be used to override default settings for an application, for example struts.devMode = false and other settings which are defined in property file. This file can be created under the folder WEB-INF/classes.

6.What is the purpose of constant tag in struts.xml?
The constant tag along with name and value attributes will be used to override any of the following properties defined in default.properties, like we just set struts.devMode property. Setting struts.devMode property allows us to see more debug messages in the log file.

7.What is the purpose of action tag in struts.xml?
We define action tags corresponds to every URL we want to access and we define a class with execute() method which will be accessed whenever we will access corresponding URL.

Results determine what gets returned to the browser after an action is executed. The string returned from the action should be the name of a result. Results are configured per-action as above, or as a “global” result, available to every action in a package. Results have optional name and type attributes. The default name value is “success”.

8.What is the purpose of struct-config.xml in Struct2?
The struts-config.xml configuration file is a link between the View and Model components in the Web Client.

9.What is the purpose of form-beans tag in struct-config.xml?
This is where you map your ActionForm subclass to a name. You use this name as an alias for your ActionForm throughout the rest of the struts-config.xml file, and even on your JSP pages.

10.What is the purpose of global-forwards tag in struct-config.xml?
This section maps a page on your webapp to a name. You can use this name to refer to the actual page. This avoids hardcoding URLs on your web pages.

You may also like

Leave a Comment