Q. Describe the core components of the Struts2 framework ?
A. The core components of the Struts2 framework are :

Actions are the core of the Struts2 framework. Each and every URL is mapped to a specific action, that provides the processing logic necessary to service the request that comes from the user. The requirement that is necessary for actions in Struts 2 is that there is a one no-argument method that returns a String or Result object. If this method i.e. no-argument method is not specified, the default action is to use the execute() method. On the other hand, need additional configuration to define the method name. When the outcome is a String object, the complementary result is obtained from the action’s configuration and instantiated. This is then used to develop a response for the user.

As Struts 2 provides  Action interface  and this Action interface only serve the common string-based return values as constants and enforce that implementing classes provide the default execute() method.

Struts 2 also  support the  ActionSupport class that provides
an implementation for the execute() method.

The four other interfaces that are also implemented they are Validateable and ValidationAware interfaces, that provide support for validation. The TextProvider and LocaleProvide interfaces provide support for localization and internationalization.


It allow for crosscutting functionality that is to be implemented separately from the action as well as the framework. This makes the core framework code awkward and able to adapt to new framework features much rapidly.

By the use of interceptors, the following can be achieved:

  1. Before the action is called it provides preprocessing logic.
  2. Interacting with the action, providing execution information when interacting with the action, such as Spring-managed objects.
  3. After the action is called it provides postprocessing logic.
  4. Modifying the result being returned, hence changing what is   rendered to the.
  5. By catching the exceptions alternate processing can be performed.

Each and every interceptor provides a specific feature that provides
a fully equipped execution environment to an action. So more than one interceptor to be applied. This is managed by allowing interceptor stacks to be created and then referenced by actions. Each interceptor is called in the order that it is configured.

The Value Stack and OGNL
The Value Stack is a basic approach in the Struts2 framework. All of
the core components interact with it in one way or another to provide access to context information as well as to elements of the execution environment.

The Value Stack is a stack implementation. Yet,
there are differences between a traditional stack implementation and the Value Stack.
The first difference is that the contents are made up of four levels in stack:

  • Temporary objects
  • Model object
  • Action object
  • Named objects

Second difference is that how the stack is used. Usually when using a stack, push objects on and pop objects off. With the Value Stack,
search, or evaluate, a particular expression using OGNL (Object Graph Navigational Language) syntax. Other expression languages, such as JSTL (JSP Standard Tag Library) or MVEL (MVFLEX Expression Language).

For the Value Stack, the OGNL expression is tested at each level, in the order they are listed. If the expression can be evaluated, the result is returned. Yet, a null value is returned. When all the levels have been failed, and a result still cannot be evaluated.

Result Types
After an action has been processed, the resulting information is send back to the user. As Struts2 supports many types of results.
The result type gives the implementation details for the type of information that is returned to the user. Result types are usually preconfigured in Struts2 or provided via plug-ins, but on the other hand developers can give custom result types as well. Configured
as the default result type is the dispatcher.


Results  define the user workflow. After the
action has been executed—even if they move to a “success” view, an “error” view, or back to the “input” view. And when the action decides not to return a fully configured Result object, then it will return a String that is the unique identifier corresponding to a result configuration for the action.

Each method on an action that is mapped to process a URL request needs to return a result, which includes specifying the result type that it uses.

View technology

Java Server Pages are being carried out as the view technology. As it may be use generally, This is not the only way to render results i.e. Java Server Pages. The result type is closely linked to the view .

The another three technologies that can replace JSPs in a Struts2 application are given below :

  1. Velocity Templates
  2. Freemarker Templates
  3. XSLT Transformations

Freemarker and Velocity are very identical to JSP. All the properties of the action are available to the template, as well as the JSP tag libraries and the use of OGNL within the tag libraries. The XSLT result is a slightly variant. Rather of replacing the template name with the stylesheet name, additional parameters are used.