Javatpoint Logo
Javatpoint Logo

Struts 2 ValueStack Tutorial

A valueStack is simply a stack that contains application specific objects such as action objects and other model object.

At the execution time, action is placed on the top of the stack.

We can put objects in the valuestack, query it and delete it.


ValueStack Interface

The struts 2 framework provides an interface to deal with valuestack. It provides many useful methods.

Methods of ValueStack interface

There are many methods in ValueStack interface. The commonly used methods are as follows:

public String findString(String expr) finds the string by evaluating the given expression.

public Object findValue(String expr) finds the value by evaluating the specified expression.

public Object findValue(String expr, Class c) finds the value by evaluating the specified expression.

public Object peek() It returns the object located on the top of the stack.

public Object pop() It returns the object located on the top of the stack and removes it.

public void push(Object o) It puts the object on the top of the stack.

public void set(String key, Object value) It sets the object on the stack with the given key. It can be get by calling the findValue(key) method.

public int size() It returns the number of objects from the stack.






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA