I have an arraylist defined and populated in a servlet. What I want to
do is pass the arraylist to a JSP and display the values in the
arraylist.
Now to accomplish this what I did was to take the request object and
set an attribute on it. The attribute I added was the ArrayList. The
problem was when the JSP receives the request and does a getAttribute
on the request it is saying the ArrayList is null.
Any ideas on how I can pass this arrayList from a servlet to a JSP?
impaler - 30 Oct 2006 18:20 GMT
On Oct 30, 5:13 pm, charlesmu...@gmail.com wrote:
> I have an arraylist defined and populated in a servlet. What I want to
> do is pass the arraylist to a JSP and display the values in the
> arraylist.
> problem was when the JSP receives the request and does a getAttribute
> on the request it is saying the ArrayList is null.
It tries to get a string from the request not the arraylist.
> Any ideas on how I can pass this arrayList from a servlet to a JSP?
Put it on the session in the servlet and retrieve it from there in the
JSP or you will have to serialize it somehow before putting it on the
request. Bear in mind that GET has a maximum allowed length. POST
doesn't.
Regards
Manish Pandit - 30 Oct 2006 20:42 GMT
> Now to accomplish this what I did was to take the request object and
> set an attribute on it. The attribute I added was the ArrayList.
This is the correct approach. However, if you are using struts and the
action is set to redirect="true", the request will never make it to the
JSP and you'd have to use the session. Unless you are changing the
model in your servlet (i.e. processing a POST), there is no reason to
use redirect.
>The
> problem was when the JSP receives the request and does a getAttribute
> on the request it is saying the ArrayList is null.
Make sure you are using the correct attribute name - it is case
sensitive.
-cheers,
Manish
Simon Brooke - 02 Nov 2006 18:42 GMT
> I have an arraylist defined and populated in a servlet. What I want to
> do is pass the arraylist to a JSP and display the values in the
[quoted text clipped - 6 lines]
>
> Any ideas on how I can pass this arrayList from a servlet to a JSP?
Cache it on the Session.

Signature
simon@jasmine.org.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/
;; Madness takes its toll. Please have exact change.