Sorta pooling the responses to this thread...

Last I looked JDBC could make database connections without reference to an
application object.

Why don't you just use the connection pooling built in to JDBC 2.0?

You don't need request time attribute values to initialize a bean. You can
write scriptlets either within the useBean tags or afterward. All
jsp:setProperty does is call a set method. You can do the same. Scriptlets
are always "request time".

(Tho it is a pain in the butt that request time attribute values are
optional. Which means: Don't use 'em. I hope other pro-standardization folk
will let Sun know how they feel about optional features.)

Otherwise, the idea of a bean that gets a connection which is used by other
beans in the same request is a good one.

Beans are Java Beans, described by the spec for same, which means no extra
arguments in get methods.

Bob Foster
Symantec Internet Tools  http://www.visualcafe.com/


______________________________ Reply Separator _________________________________
Subject: Re: How to access JSP beans from each other ?
Author:  Drew Cox <[EMAIL PROTECTED]> at Internet
Date:    5/4/99 3:21 PM


Well done Scott, it's good to see some people have been able to digest
the 100+ pages of the new spec and make some sense of it (I'm still on
my 1st reading.....)

I think I understand what you are saying here.  It seems that this
method requires the explicit passing of some type of a context object,
that the bean method then uses to get access to object stored in the
required scope, such as the implicit application object.  This requires
the embedding of scriptlets, which I would like to avoid, not much hope
with 1.0 though :-{

It would be nice if this context object was somehow available implicitly
in every bean method, so that I could access it from the getXxx method
that is called when you use a <jsp:getProperty> tag, without extra work.
Maybe if the engine automatically passed the pageContext to all getXxx
bean methods ?

Still, the runtime attribute mechanism looks like it can provide
something equivalent.

Thanks for you suggestions,

Drew Cox
Barrack Consulting

> -----Original Message-----
> From: Scott Ferguson [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, 4 May 1999 13:45
> To:   [EMAIL PROTECTED]
> Subject:      Re: How to access JSP beans from each other ?
>
> This is one of the cool things about JSP 1.0.  Beans are stored in
> their
> corresponding scope variable.
>
> So, application scope beans are stored in the 'application' implicit
> variable.  You can then pass the application object (or the
> pageContext) to
> the bean.
>
> <jsp:useBean id='DBConnection' class='com.caucho.sql.DBConnection'
> scope='application'/>
> <jsp:useBean id='test' class='com.caucho.test.Test'/>
>
> <%
>   test.doSomethingCool(application);
> %>
>
> Where 'doSomethingCool' uses application.getAttribute("DBConnection")
> to get
> the database connection.
>
> Or if your JSP engine supports request time attribute values, you
> could
> initialize test by:
>
> <jsp:useBean id='test' class='com.caucho.test.Test'>
>   <jsp:setProperty name='test' property='pageContext' value='<%=
> pageContext
> %>'/>
> </jsp:useBean>
>
> Then you could pull out the connection using:
>   pageContext.getServletContext().getAttribute("DBConnection");
>
> Scott Ferguson
> Caucho Technology
>
> Drew Cox wrote:
>
> > I hope l'm missing something simple, but how do you get a reference
> to a
> > JSP bean defined with USEBEAN from within another JSP bean ?
> >
> > Specifically, l would like to do some simple DB connection pooling
> by
> > creating an "application" scope bean "DBConnection", that loads the
> JDBC
> > driver & creates a connection object which it stores in an instance
> > variable.
> >
> > This would do some checking to ensure it was only created once.
> >
> > The idea is that other beans used on the JSP page could access the
> > connection stored in the "DBConnection" bean to create their query
> > statements.
> >
> > But, l can't find a method by which l can get access to other beans
> > defined at any JSP scope level from wlthin the bean code.
> >
> > Thanks
> > Drew
> >
> >
> ======================================================================
> =====
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in
> the body
> > of the message "signoff JSP-INTEREST".  For general help, send email
> to
> > [EMAIL PROTECTED] and include in the body of the message "help".
>
> ======================================================================
> =====
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> of the message "signoff JSP-INTEREST".  For general help, send email
> to
> [EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to