jQuery in Action, 2nd edition*
The moose likes Servlets and the fly likes need help returning array bean object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "need help returning array bean object" Watch "need help returning array bean object" New topic
Author

need help returning array bean object

kwame Iwegbue
Ranch Hand

Joined: Sep 02, 2000
Posts: 197
I know this is probably just a problem with the way my while loop is structured, but this is giving me a headache!!!



There are about 10 rows of info, with different names and location etc, but
when i run the code, the JSP displays the same info for all the bean objects- and it happens to be the info from the last row in the join table.

is it the while loop, or something with ResultSet? is there a different way to do this?


Who dares, wins! (SAS motto)
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You only have one bean, and all 10 elements in the array refer to that same bean. And because you keep changing its data, when the code is all done, it contains the last row from the table.

I don't know why your method is designed to have a PatientBean as a parameter, but that bean is of no use to you. You need to create 10 beans, one for each row. Like this:
kwame Iwegbue
Ranch Hand

Joined: Sep 02, 2000
Posts: 197
Paul...you rock!
It works!
Thanks for the quick and helpful reply!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: need help returning array bean object
 
Similar Threads
accessing values from servlets to jsp
How to retrieve the first record in a database table
how to improve my program code ?
Retriving data from java class to servlet to jsp
Retriving data from java class to servlet ---> jsp