Value Stack / OGNL

Object Graph Navigational Language (OGNL) is a open source framework used to get properties from Java Beans. In Struts 2 framework, OGNL provides way to access objects within the value stack.

Value Stack / OGNL


Value Stack / OGNL

Object Graph Navigational Language (OGNL) is a open source framework used to get properties from Java Beans. In Struts 2 framework, OGNL provides way to access objects within the value stack.

OGNL is a fully featured expression language. In Struts 2 framework, it works along with Value Stack to handle requests.

OGNL uses dot notation to navigate object graphs.

OGNL also supports following features:

  • type conversion
  • calling methods
  • collection manipulation and generation
  • projection across collections
  • expression evaluation
  • lambda expressions

Value Stack is a stack of objects. Whenever a user sends a request a Value Stack object is created. Value Stack also gets the references to request attributes, Session attributes and Application context.

Value Stack has following objects:

  1. Temporary Objects
  2. Model Object
  3. Action Object
  4. Named Objects

Control Tags along with expression are used to access properties of objects in value stack.

Data Tags are used to manipulate the value stack.

If the value you are querying about exists in the value stack, it will be returned regardless of where it is - the action, the model, or the HTTP request. Every element is queried for the value till it is found or stack ends.

However, if the property is common than the value returned may not be what you expect.