This is my code below, when I execute it shows me the size 3, but when I pop the object out I am getting only 2 objects.
import java.util.*;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class HelloWorldAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private String name;
public String execute() throws Exception {
ValueStack stack = ActionContext.getContext().getValueStack();
Map<String, Object> context = new HashMap<String, Object>();
context.put("key1", new String("This is key1"));
context.put("key2", new String("This is key2"));
context.put("key3", new String("This is key3"));
stack.push(context);
System.out.println("Size of the valueStack: " + stack.size());
for (int i = 0; i < stack.size(); i++) {
System.out.println(i + ": " + stack.pop().toString());
}
return "success";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Please, explain me whether I am doing it wrong?
Wnd I want to know that what are the objects stored in ValueStack
and how can I retrieve those objects?