File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Help please! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Help please!" Watch "Help please!" New topic

Help please!

Bala Krishniah
Ranch Hand

Joined: Dec 14, 2000
Posts: 81
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.
Katie McCann
Ranch Hand

Joined: Jul 24, 2000
Posts: 45
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

Joined: Dec 14, 2000
Posts: 81
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).
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
It's important to understand that in Java, an array is an Object, just like the other aggregations (Hashtable, vector, List, Map, etc. etc.)

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
I agree. Here's the link:
subject: Help please!
It's not a secret anymore!