Home / Interview / Struts :: General Questions

Interview :: Struts

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?

No. Struts1 Struts2
1) 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.
2) Front controller is ActionServlet. Front Controller is StrutsPrepareAndExecuteFilter.
3) It uses the concept of RequestProcessor class while processing request. It uses the concept of Interceptors while processing the request.
4) It has only JSP for the view component. It has JSP, Freemarker, Valocity etc. for the view component.
5) Configuration file name can be [anyname].xml and placed inside WEB-INF directory. Configuration file must be struts.xml and placed inside classes directory.
6) Action and Model are separate. Action and Model are combined within action class.
3) 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.

mvc architecture

4) What is interceptor?

Interceptor is an object i.e. invoked at preprocessing and postprocessing of a request. It is pluggable.

5) What are the life cycle methods of interceptor?
  • public void init()
  • public void intercept(ActionInvocation ai)
  • public void destroy()
6) What is ValueStack?

ValueStack is a stack that contains application specific object such as action and other model.

7) What is ActionContext?

ActionContext is a container in which action is executed. It is unique per thread.

8) What is ActionInvocation?

ActionInvocation is responsible to invoke action. It holds action and interceptor objects.

9) What is OGNL?

OGNL is an expression language of struts2. It stands for Object Graph Navigation Language.

10) What are the 5 constants of Action interface?
  1. SUCCESS
  2. ERROR
  3. INPUT
  4. LOGIN
  5. NONE