Struts - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

Struts 2 Components

Struts 2 Components

shape Description

Struts 2 Components, a request is forwarded to an action class from the browser and returns the result in a browser in between container. Struts framework will contain components where each component can be treated as a core component of the struts framework, these components are utilized to develop web applications but having knowledge of these components is mandatory to learn Struts framework. Following are the Struts 2 Components and their overview.

Interceptors

shape Description

Interceptor is an object, that is invoked (executed) the pre-processing request and post-processing request. Interceptors are used to perform the validations, exceptions handling and display the result in between the execute() method. In struts 2, Interceptors execution is same as the servlet filter execution type. Using Interceptors, One can run the application using validations, and can remove the validations on that application and one cannot deploy the application in the server. If it directly run on the server.

ValueStack

shape Description

ValueStack is a type of stack, it contains some objects or requests. ValueStack is used for hiding some data internally and execute in execute() method.

ActionInvocation

shape Description

The ActionInvocation represents the execution state of an action. It holds the action and interceptor objects. ActionInvocation is an interface, it provides some methods by calling the ValueStack, ActionProxy, ActionContext.

shape Methods

Methods of ActionInvocation Interface.

OGNL

shape Description

OGNL (Object Graph Navigation Language) is one type of Expression Language. OGNL is used to simplify the ActionContext contains data. These OGNL expressions are used to display the ValueStack object values in browser. Push the values in ValueStack object, then the values is mapped to JSP pages through property tag. [java]<s:property value="username"/> [/java] Here, s indicates prefix and name indicate the ValueStack object property key.The struts framework places other objects in ActionContext. The ActionContext map represent the request, session, application scopes.To get the values in scope, the action property is not directly used. So, one need to use # notation.

Summary

shape Key Points

  • Struts 2 Components - The components are the core of Struts 2.
  • Struts 2 Components - OGNL stands for Object Graph Navigation Language.
  • Value Stack is the root instance of OGNL.