Hello All, I was hoping somebody can shine a light on the problem I'm having trouble with.
If I have a JSP page which uses a bean ("DBBean").
DBBean is a 'page scope' bean and is used to connect to a DBCP
Now I want to refer to a second bean in which is code to return certain data...
My question is how do I get the 2nd bean to be aware of the DB connection in the first bean ?
Thanks for any advice in advance.
Regards, Dave Brown
SCJP 6 - [url]http://www.dbws.net/[/url] - Check out Grails Forum
Joined: Feb 16, 2005
first, i assume that you already aware that you are using a 'page scope' bean which means it can only be accesed from the same page. second, in order to have a second bean that can refer to the first bean, you should use both of the bean at the same page third, in the second bean you should have at least 1 bean property (function) which has parameter related to the first bean, for example : <jsp:usebean="first"......scope="page"/> <jsp:usebean="second"......scope="page"/> <% Connection con = first.getConnection(); /* assume this bean return a connection named con */ /*assume we want to retrieve data with a select query written in the function getData int second bean property, which will be like, for instance : private ResultSet getData(Connection c).....*/ ResultSet rs = second.getData(con); ... ... ... well that's all i can say, hope it helps and if there's any blur about my explanation just ask i'll be around OK? regards %>
Joined: Mar 08, 2005
Hi, Thannks for the reply. I see there will still be the need of scripting there, I wont be able to get away with just using EL I dont think. Hmmm