Latest Struts Interview Questions
1) What is Struts?
Struts is a framework for developing MVC-based framework. Struts2 is the combination of Webwork and struts1 frameworks.
2) What is the difference between struts1 and struts2?
Struts1
Action class is not POJO. You need to inherit abstract class.
Front controller is ActionServlet.
It uses the concept of RequestProcessor class while processing request.
It has only JSP for the view component.
Configuration file name can be [anyname].xml and placed inside WEB-INF directory.
Action and Model are separate.
Struts2
Action class is POJO. You don’t need to inherit any class or implement any interface.
Front Controller is StrutsPrepareAndExecuteFilter.
It uses the concept of Interceptors while processing the request.
It has JSP, Freemarker, Valocity etc. for the view component.
Configuration file must be struts.xml and placed inside classes directory.
Action and Model are combined within action class.
3) What are the features of Struts?
Configuration MVC components
POJO based action
AJAX Support
Various Tag Support
Various Result Types
Integration Support
4) What is MVC?
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.
5) What is interceptor?
Interceptor is an object i.e. invoked at preprocessing and postprocessing of a request. It is pluggable.
6) What are the life cycle methods of interceptor?
public void init()
public void intercept(ActionInvocation ai)
public void destroy()
7) What is ValueStack?
ValueStack is a stack that contains application specific object such as action and other model.
8) What is ActionContext?
ActionContext is a container in which action is executed. It is unique per thread.
9) What is ActionInvocation?
ActionInvocation is responsible to invoke action. It holds action and interceptor objects. More details…
10) What is OGNL?
OGNL is an expression language of struts2. It stands for Object Graph Navigation Language.
11) What are the 5 constants of Action interface?
SUCCESS
ERROR
INPUT
LOGIN
NONE
12) What does params interceptor?
The params (also known as parameters) interceptor sets all parameters on the ValueStack.
13) What does execAndWait interceptor?
The execAndWait (also known as ExecuteAndWait) interceptor is used to display intermediate or wait result.
14) What does modelDriven interceptor?
The modelDriven interceptor makes other model as the default object of ValueStack. By default, action is the default object of ValueStack.
15) What does validation interceptor?
The validation interceptor performs validation checks and adds field-level and action-level error messages.
16) What are the bundled validators?
requiredstring
stringlength
email
date
int
double
url
regex
17) What is the difference between plain-validator and field-validator?
In plain-validator one validator can be applied to many fields. In field-validator many validators can be applied to single field.
18) What is the use of jsonValidation?
The jsonValidation interceptor is used to perform asynchronous validation. It works with validation and workflow interceptors.
19) What are the aware interfaces in struts2?
Aware interfaces are used to store information in request, session, application and response objects.
The 4 aware interfaces are given below:
ServletRequestAware
ServletResponseAware
SessionAware
ServletContextAware
20) What does i18n interceptor?
The i18n interceptor is used to provide multi lingual support for struts application.