Forums Register Login

JSP, beans and sharing ArrayLists

+Pie Number of slices to send: Send
Hi guys,
I'm at it again, probably doing it the wrong way. The following code works great;


It lists an ArrayList that's generated by a bean. Great. Later, I wanted to pick off the first object in that ArrayList so I repeated the same code and I keep getting null stuff. I tried tsSale.get(0).object.getUname() without success. I tried putting the ArrayList into a session bean object. Nope.

Two questions:

1. Can you put an ArrayList into a session bean?

2. Can one bean create instances/objects of another session bean that can be accessed throughout the session?

3. Should I be using Struts?

Thanks.

Chris
+Pie Number of slices to send: Send
 

Originally posted by Chris Baty:
Hi guys,
I'm at it again, probably doing it the wrong way. The following code works great;


We're rather interested in the code which didn't work.


It lists an ArrayList that's generated by a bean. Great. Later, I wanted to pick off the first object in that ArrayList so I repeated the same code and I keep getting null stuff. I tried tsSale.get(0).object.getUname() without success. I tried putting the ArrayList into a session bean object. Nope.


You need to elaborate a bit more about "I keep getting null stuff".


Two questions:

1. Can you put an ArrayList into a session bean?


Yes.


2. Can one bean create instances/objects of another session bean that can be accessed throughout the session?


It can, yes. But if it is recommendable? Can't say more as long as your functional requirement is unclear.


3. Should I be using Struts?


Not necessarily. Get a good grasp on plain Java/JSP/JSTL/EL first.
+Pie Number of slices to send: Send
Here's a test JSP that doesn't work but is the same code I used before:


I'm trying to pick off the first object and put the uname element into a session bean. This is the method that generates the ArrayList:



Here, I tried to put the ArrayList into another session bean, without apparerent success. I'm learning a lot but becoming frustrated.


Thanks.

Chris
+Pie Number of slices to send: Send
I decided to go back to the basics, so I wrote a simple bean:


Then I wrote a JSP:


It worked Great. Hope this helps others.

Chris
Onion rings are vegetable donuts. Taste this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 4034 times.
Similar Threads
Regarding jsp quote symbol error
jstl, ArrayLists and object instances?
Calling JSP with in WEB-INF
trying to submit a form using hyperlink (href)
How to set a request parameter in a JSP and pass it in a c:param tag?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 19:33:07.