What is the exact error message?
Have you actually put something there before you tried to access it? Ask
whether what you get from the servlet context is not null first and then try to
cast it if it is not null.
(I don't know the exact class names)
sContext.setAttribute("com.javaechnage.DatabasePool",DatabasePool);
DatabasePool dPool =
(DatabasePool)sContext.getAttribute("com.javaechnage.DatabasePool");
dave.
Sajesh T wrote:
> Hi,
> Thanks for the suggestion.
> I tried this, by storing the connectionpool reference
> in the servlet context. (using setAttribute())
> But when I try to access it from another servlet, (using
> the getAttribute() method) I am getting a ClassCastException! Why is this?
> Can you please explain how you are storing and retrieving the object from
> the ServletContext?
>
> Thanks
> Sajesh
>
> On Tue, 23 Nov 1999 12:32:38 -0500, David Mossakowski wrote:
>
> > In servlet's init method check if your context has attribute databasePool
> that's
> > not null. If it is null then you know that the pool hasn't been loaded
> into
> > context and it's the first servlet being loaded by the engine so put the
> pool in
> > there.
> >
> > Then have each servlet do that in its init method so that if some servlet
> has
> > already put the connection pool into the context the next one won't do it
> too.
> >
> > dvae.
> >
> > Sajesh T wrote:
> >
> > > Hi all
> > > Presently i am working on a project which making use of
> > > Netscape Enetrprise Server 4.0 in which i am making use
> > > of a static connection pool object to establish connection to an Oracle
> > > database. My problem is, I am not able to
> > > share this connection pool object across my servlets.
> > > Each servlet is loading its own Connection pool object
> > > and this exhausts my maximum number of connections.
> > > I tried by including the path of my connection object class in the jre
> class
> > > path (in the NES server admin) and jvm12.conf file of NES, but nothig
> is
> > > found to be working.
> > > When I did this, i was getting a 'no suitable driver' message. If I put
> the
> > > connection pool object in my servlet dir, everything works fine, but
> each
> > > servlet loads its own copy of connection pool.
> > > Please someone out there help me,
> > > thanks in advance
> > > sajesh
> > >
> > > ________________________________________________________________
> > > Get FREE voicemail, fax and email at http://voicemail.excite.com
> > > Talk online at http://voicechat.excite.com
> > >
> > >
> ___________________________________________________________________________
> > > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> > > of the message "signoff SERVLET-INTEREST".
> > >
> > > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > > Resources: http://java.sun.com/products/servlet/external-resources.html
> > > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >
> > --
> > David Mossakowski [EMAIL PROTECTED]
> > Programmer 212.310.7275
> > Instinet Corporation
> >
> > "I don't sit idly by, I'm planning a big surprise"
> >
> >
> ___________________________________________________________________________
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > Resources: http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
> ________________________________________________________________
> Get FREE voicemail, fax and email at http://voicemail.excite.com
> Talk online at http://voicechat.excite.com
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
--
David Mossakowski [EMAIL PROTECTED]
Programmer 212.310.7275
Instinet Corporation
"I don't sit idly by, I'm planning a big surprise"
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html