• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help please!

 
Bala Krishniah
Ranch Hand
Posts: 81
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a problem.
The servlet is sending an array of objects of a class BB.
How do I access that this array in my JSP.
Thanks
 
Katie McCann
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can store the array in either the session object or in the request object- put code something like this in the servlet:
To store in the session:
HttpSession sess= request.getSession();
sess.putValue("myarray", BBarray);
Then to access it from the JSP:
BB [] arr= (BB[])session.getValue("myarray");
To store in the request:
request.setAttribute("myarray", BBarray);
To access it in the JSP:
BB [] arr= (BB[])request.getAttribute("myarray");
 
Bala Krishniah
Ranch Hand
Posts: 81
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Katie McCann.
But the document says that the getAttribute returns the object bound with the specified name . Does that mean only one object or whatever we set using setAttribute. (ie it can be a single object or array of object).
Thanks
 
Frank Carver
Sheriff
Posts: 6920
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's important to understand that in Java, an array is an Object, just like the other aggregations (Hashtable, vector, List, Map, etc. etc.)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic