0

I'm developing an struts App. In one of the actions I instantiate an object, once instantiated i need that object to be available in other actions for the user using the App.

Is there a way to store a whole object in the http session in Struts 1.3?

Roman C
  • 49,761
  • 33
  • 66
  • 176

1 Answers1

0

We can store and retrieve any object.

In Action1 use:

  private ArrayList<Integer> obj= new ArrayList<Integer>();
  .............
  session.setAttribute("objname", obj);//to store

In Action2 use:

  ArrayList<Integer> obj1= (ArrayList<Integer>)session.getAttribute("objname");//to retrieve

Syntax:

 setAttribute(java.lang.String name, java.lang.Object value) 
SatyaTNV
  • 4,137
  • 3
  • 15
  • 31