Jeff Behl wrote:
>
> What's the best way to do this on a bean that only has request scope?  it
> doesn't make much sense to have a database pool instantiated every time
> the bean is.  Without goign to an EJB model, is placing a database pool in
> the bean via a scriplet a viable option?
>
> basically, I want to use the same bean on a number of product web pages to
> display product specific information.  Current plan is to have a
> setProperty method that sets the ProductID (primary key) on each page
> which allows the bean to grab the product information.  If anyone has a
> better way to do this, I'd love to hear about it.

You can place the pool as an application scope attribute (e.g. let a servlet
loaded at startup create it and save it as a context attribute), and then
use bean setter method to set it:

  <jsp:useBean id="foo" class="com.mycomp.FooBean" >
    <jsp:setProperty name="foo" property="pool"
      value="<%= application.getAttribute(\"pool\") %>" />
    <jsp:setProperty name="foo" property="prodID"
      value="<%= request.getParameter(\"prodID\") %>" />
  </jsp:useBean>

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to