Exercise 4 : Additional Lab Exercise

Note : This lab is not mandatory, it is there if you would like to take things further. There is little or no sample code although it is suggested that you use the code from the initial lab exercise as a starting point.

Using a session bean to access the database

The results of this lab exercise are identical to the previous additional lab exercise. However rather the hard code the JDBC code into the servlet, in this lab we shall make use of a Session Bean. Create a Session bean and move the JDBC code from the servlet into said Session bean. The remote interface for the bean needs to describe functionality which will enable the results of the database query to be returned to the servlet. The servlet can then pass the results to the JSP page for display as normal.

Extension

It would be a nice idea to type a servlet HttpSession with the Stateful Session bean. To do this use the code which was shown at the end on module 6 with deals with handles and integrate it into your servlet. You could write a simple Stateful Session bean which acts as a counter.


© Steve Ferris 2000