1.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.What are the core components of a Struct2 based application?The Model-View-Controller pattern in Struts2 is realized with following five core components −
3.Explain the life cycle of a request in Struct2 application.?Following is the life cycle of a request in Struct2 application −
4.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. 5.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. 6.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. 7.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. 8.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. 9.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. 10.What is the purpose of action-mappings tag in struct-config.xml?This is where you declare form handlers and they are also known as action mappings. 11.What is the purpose of plug-in tag in struct-config.xml?This section tells Struts where to find your properties files, which contain prompts and error messages. 12.What is the purpose of struts.properties in Struct2?This configuration file provides a mechanism to change the default behavior of the framework. Actually all of the properties contained within the struts.properties configuration file can also be configured in the web.xml using the init-param, as well using the constant tag in the struts.xml configuration file. But if you like to keep the things separate and more struts specific then you can create this file under the folder WEB-INF/classes. The values configured in this file will override the default values configured in default.properties which is contained in the struts2-core-x.y.z.jar distribution. 13.What are interceptors in Struts 2?Interceptors are conceptually the same as servlet filters or the JDKs Proxy class. Interceptors allow
for crosscutting functionality to be implemented separately from the action as well as the
framework. You can achieve the following using interceptors −
14.How can you create your custom interceptor in Struts 2?Creating a custom interceptor is easy; the interface that needs to be extended is the Interceptor interface. 15.How interceptor works in Struts 2?Actual action will be executed using the interceptor by invocation.invoke call. So you can do some
pre-processing and some post-processing based on your requirement. 16.What are Result types in Struts?The Action class manages the application's state, and the Result Type manages the view. 17.What is defeult result type?Default result type is dispatcher, which is used to dispatch to JSP pages. 18.What is the purpose of dispatcher result type?The dispatcher result type is the default type, and is used if no other result type is specified. It's used to forward to a servlet, JSP, HTML page, and so on, on the server. It uses the RequestDispatcher.forward method. 19.What is the purpose of redirect result type?he redirect result type calls the standard response.sendRedirect method, causing the browser to
create a new request to the given location. We can provide the location either in the body of the
20.What is Value Stack?The value stack is a set of several objects which keeps the following objects in the provided order
−
|