• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using DataSource object with JNDI

 
Ricky James
Ranch Hand
Posts: 83
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.

Thanks
Ricky

[ April 02, 2007: Message edited by: Ricky James ]
[ April 02, 2007: Message edited by: Ricky James ]
 
Jan Cumps
Bartender
Posts: 2577
11
C++ Linux Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Open html table

Then, for each bean in the array:
create a table row,
get the current bean's property values
enter these values in the table columns

close the html table

Regards, Jan
[ April 02, 2007: Message edited by: Jan Cumps ]
 
Ricky James
Ranch Hand
Posts: 83
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


Regards, Jan

[ 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
 
Jan Cumps
Bartender
Posts: 2577
11
C++ Linux Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's an assignment, I think the solution has to come from yourself.
Read the info, and apply it.
Regards, Jan
 
Ricky James
Ranch Hand
Posts: 83
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jan Cumps:
If it's an assignment, I think the solution has to come from yourself.
Read the info, and apply it.
Regards, Jan


You are correct Jan.
And I am trying.
Thanks
Ricky
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic