I am working on this exercise and would be thankful if somebody could point me in the right direction to tackle it.
Create a servlet that displays a list of customers (From the customer table of the database). Use the HTML table to organize the display.
Hint: Use a Java Bean, e.g. CustomerBean that has the fields of �First Name�, �Last Name� and �Date of Birth�. And when the query returns the result set, you will need to populate each CustomerBean and add them to an ArrayList. Then return the collection object to the servlet, loop through the collection and display the result.
I have learnt to display data in an html table directly from a servlet connected to a database via jdbc. But I do not understand how to use a JavaBean to attain that as advised in the 'hint'.
I do not expect the solution but suggestions are welcome. If you know of any online resource, or a book that deals with this topic, it would be really helpful.
[ April 02, 2007: Message edited by: Ricky James ] [ April 02, 2007: Message edited by: Ricky James ]
Originally posted by Jan Cumps: If you're using Tomcat, then this is a good guide: Apache Tomcat 6.0 JNDI Datasource HOW-TO. Shows how to configure the thing in tomcat, and how to use it in your servlet.
The use of the javabean is almost completely explained in your assignment:
Create a bean with variables to hold the table's values. Query the table, and for each row found:Create a new bean. Populate the bean's variables with the table values. Add the bean to your array.
[ April 02, 2007: Message edited by: Jan Cumps ]
Thanks again Jan. I've visited this site but I am looking for a resource which has specific examples regarding this. Ricky