Make sure that both your initialization Servlet (that puts the dbPool into context) and your application JSP are in the same context (i.e. The same Web Application), then (just for ease of use) you might try pageContext.findAttribute("dbPool"); or pageContext.getAttributeScope("dbPool"); to find out what scope it's actually in.
  (*Chris*)
----- Original Message -----
Sent: Tuesday, September 24, 2002 9:29 AM
Subject: [SERVLET-INTEREST] Custom Tag retrieving ServletContext Objext

Hi Everyone,
 
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 for your time,
Jason

Reply via email to