Wednesday, July 31, 2002 01:16 PM
I hide all my database connection code (as well as data loading) in my bean, and simply initialize it in my jsp at which point it connects, loads my data into the bean and disconnects. The jsp code is as follows:
<%@ page import = "com.blah.beans.*" %>
where myBeanClass is the name of your bean class file, myBean is the name of your bean if you need to use it in the jsp file and session will keep your bean alive for the life of the session object. the import should point to the package you keep your beans in.
if you put methods in your bean to manipulate the data stored in it you can access them in the jsp like so:
In your beans init code simply create the connections and do what you need to do and it will be ready to go for use within your jsp, just do the useBean call up top of your jsp file.
<%= myBean.myMethod(); %>
Hope this helps,