This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
I am working on an exercise in "Murach's Servlets & JSP" where i am trying to add code to a method in order to return an arrayList of objects. Here is the code below:
In the latter part of the code, i've added code to the "selectUsers" method to return an arrayList of User objects that corresponds with the rows in the User table. When I run the program, it compiles and brings up the page, and when I click on the link to display users, it only shows the table heading.
Please advise as to what I am doing wrong. Is something wrong with the arrayList?
If you need any additional information from me, please let me know. Thanks in advance.
The first thing I can see which is wrong is that, although you declare the method to return an ArrayList of User objects, you're putting three Strings into the ArrayList and returning that. Based on the name of the method, I would expect to see some JDBC code that did this:
Go through the whole User table.
Create a User object from each row of the table and add it to an ArrayList.