You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jason Johnston <EP...@epa.state.il.us> on 2002/09/24 18:24:42 UTC
Retrieving ServletContext Objects via PageContext
This may be a stupid question but I'm just starting to use custom tags and I'm running into a strange problem. I'm using a DBCP for a mySQL database and my setup servlet places a handle to the pool in the ServletContext via the setAttribute() under the name "dbPool."
Now other servlets can retrieve the pool handle fine and get a connection and do their business. However my tag, which extends TagSupport can't seem to find the pool. Initially, I used getServletContext.getAttribute("dbPool"). Of course, I got a compile error telling me that there is no such method.
After some reading, it appeared that what I'm looking for should be available via
the pageContext.getAttribute("dbPool",pageContext.APPLICATION_SCOPE);
However, I'm still not getting a handle on the DB Pool. I know there's probably somethings fairly simple I'm missing here, either syntax or concept. Could someone give me some insight. Thanks.
RE: Retrieving ServletContext Objects via PageContext
Posted by jon wingfield <jo...@mkodo.com>.
The following will work:
pageContext.getServletContext().getAttribute("dbPool");
-----Original Message-----
From: Jason Johnston [mailto:EPA2466@epa.state.il.us]
Sent: 24 September 2002 17:25
To: <"Tomcat Users List"
Subject: Retrieving ServletContext Objects via PageContext
This may be a stupid question but I'm just starting to use custom tags and
I'm running into a strange problem. I'm using a DBCP for a mySQL database
and my setup servlet places a handle to the pool in the ServletContext via
the setAttribute() under the name "dbPool."
Now other servlets can retrieve the pool handle fine and get a connection
and do their business. However my tag, which extends TagSupport can't seem
to find the pool. Initially, I used
getServletContext.getAttribute("dbPool"). Of course, I got a compile error
telling me that there is no such method.
After some reading, it appeared that what I'm looking for should be
available via
the pageContext.getAttribute("dbPool",pageContext.APPLICATION_SCOPE);
However, I'm still not getting a handle on the DB Pool. I know there's
probably somethings fairly simple I'm missing here, either syntax or
concept. Could someone give me some insight. Thanks.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>