Struts Interview Questions
241) What is Struts?
Ans: Struts is a framework for developing MVC-based framework. Struts2 is the combination of Webwork and struts1 frameworks.
242) What is the difference between struts1 and struts2?
|Action class is not POJO. You need to inherit abstract class.||Action class is POJO. You don't need to inherit any class or implement any interface.|
|Front controller is ActionServlet.||Front Controller is StrutsPrepareAndExecuteFilter.|
|It uses the concept of RequestProcessor class while processing request.||It uses the concept of Interceptors while processing the request.|
|It has only JSP for the view component.||It has JSP, Freemarker, Valocity etc. for the view component.|
|Configuration file name can be [anyname].xml and placed inside WEB-INF directory.||Configuration file must be struts.xml and placed inside classes directory.|
|Action and Model are separate.||Action and Model are combined within action class.|
243) What are the features of Struts?
- Configuration MVC components
- POJO based action
- AJAX Support
- Various Tag Support
- Various Result Types
- Integration Support
244) What is MVC?
Ans: MVC is a design pattern. MVC stands for Model, View and Controller. Model represents data, view represents presentation and controller acts as an interface between model and view.
245) What is interceptor?
Ans: Interceptor is an object i.e. invoked at preprocessing and postprocessing of a request. It is pluggable.
246) What are the life cycle methods of interceptor?
- public void init()
- public void intercept(ActionInvocation ai)
- public void destroy()
247) What is ValueStack?
Ans: ValueStack is a stack that contains application specific object such as action and other model.
248) What is ActionContext?
Ans: ActionContext is a container in which action is executed. It is unique per thread.
249) What is ActionInvocation?
Ans: ActionInvocation is responsible to invoke action. It holds action and interceptor objects.
250) What is OGNL?
Ans: OGNL is an expression language of struts2. It stands for Object Graph Navigation Language.
251) What are the 5 constants of Action interface?
252) What does params interceptor?
Ans: The params (also known as parameters) interceptor sets all parameters on the ValueStack.
253) What does execAndWait interceptor?
Ans: The execAndWait (also known as ExecuteAndWait) interceptor is used to display intermediate or wait result.
254) What does modelDriven interceptor?
Ans: The modelDriven interceptor makes other model as the default object of ValueStack. By default, action is the default object of ValueStack.
255) What does validation interceptor?
Ans: The validation interceptor performs validation checks and adds field-level and action-level error messages.
256) What are the bundled validators?
257) What is the difference between plain-validator and field-validator?
Ans: In plain-validator one validator can be applied to many fields. In field-validator many validators can be applied to single field.
258) What is the use of jsonValidation?
Ans: The jsonValidation interceptor is used to perform asynchronous validation. It works with validation and workflow interceptors.
259) What are the aware interfaces in struts2?
Ans: Aware interfaces are used to store information in request, session, application and response objects. The 4 aware interfaces are given below:
260) What does i18n interceptor?
Ans: The i18n interceptor is used to provide multi lingual support for struts application.