My comments below:

On 5 Jul 2001, at 17:40, Erik Morton wrote:

> So many ways.....
>
> One way:
> Have your connection manager class implement the Singleton design pattern. If your 
>not familiar with this design pattern, this means that there will only be one 
>instance of the class per JVM per class loader. You'll have a public getInstance() 
>method that will return a reference to the
connection manager - you'll call this method from your JSP.
>
> Another way is to place the Connection manager in the ServletContext as an 
>attribute. You may want to set the attribute at the setup of the application server 
>(use <load-on-startup>1</load-on-startup> in the <servlet> element of 
>web.xml).........
> All of your JSP will do something like:
>
> ConnectionManager c = 
>(ConnectionManager)application.getAttribute("com.yoursite.ConnectionManager");
>
> That's all I can think of now.
>
I could be wrong here but isn't what you are doing in this second
case the same as doing what I was planning no doing with the:

<jsp:useBean id="myConnectionPool"
class="ConnectionManager"
scope="application"/> on every page?

>From what I understand doing the above would go ahead and put
the
ConnectionManager into the ServletContext if it's not already there.
Unless I'm missing something it seems simpler to just use the
useBean
syntax.

I was wondering if there was a way around having to do that on
every
page though.  If I do the above just once (say on the login page)
will that ConnectionManager remain in the ServletContext for any of
my applications' classes to use EVEN if every JSP does not have
the
useBean scriplet up top (or a specific call to the ServletContext to
get it)?  In other words say the following takes place:
1) User logs in ( JSP page sets the ConnectionManager in the
ServletContext with application scope )
2) user goes to some other page WITHOUT any <jsp:useBean
ConnectionManager >
3) This JSP page calls a method in some class. That method in
the
class grabs a connection from the connection pool(???)

..Question.. would the method call in the class in step 3 above
have
access to the ConnectionManager in the servletContext or would it
be
gone since the jsp page in step2 did not have the
ConnectionManager
defined anywhere???

Thanks so much for any help.
Rick













> Rick Reumann wrote:
>
> > I apologize if this is too basic a question for this list. If so you feel free to 
>flame me.
> >
> > First off, if the design issues are bad here to start with please tell me.
> > Anyway say I have a connection pool ( ConnectionManater.java ). Then I also have 
>several different classes that have methods that do DB stuff and they get their 
>connections from this pool. Now I have JSPs for the front end that call these methods.
> >
> > The question I have is there a "best" way to load up the ConnectionManager for the 
>application? I was just going to use a <jsp:useBean ..> tag on every jsp page with 
>the ConnectionManager having application. Is there a better way to do it so that all 
>of the methods called from the classes
have access to the connection pool?  Since before any user can use the application 
they will have to go to a login page I was thinking maybe there is something I can do 
just once on the login page that will set up the ConnectionManager and I then wouldn't 
need to have to include the useBean tag
on the top of every other page. Maybe I'm doing it the best way, but I'd like some 
suggestions if there are other ways.
> > Thanks so much,
> > Rick
> >
> > ===========================================================================
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
> > Some relevant FAQs on JSP/Servlets can be found at:
> >
> >  http://java.sun.com/products/jsp/faq.html
> >  http://www.esperanto.org.nz/jsp/jspfaq.html
> >  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> >  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
> --
> Erik I Morton
> Software Developer
> ------------------
> CommerceHub
> http://www.commercehub.com
> 518-886-0704
> 21 Corporate Drive
> Clifton Park, NY 12065
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>



_______________________________

Rick Reumann
Outback Steakhouse
IT - Internet Development
(813) 282-1224 ext. 1044

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to