Haiping Lian wrote:
>
> Hello,
>
> Does anybody know how to use database connection pool program
> (http://webdevelopersjournal.com/columns/connection_pool.html)
> Between JSP, SERVLET and BEANS?
To use any connection pool with JSP, the one in the article or
another one, I suggest you use a servlet to make a single instance
available in the ServletContext as an attribute. If you configure the
servlet to be loaded when the server starts, it can put the pool instance
in a ServletContext attribute in its init() method, where all JSP pages
can get to it through the application scope. In its destroy() method, it
can shut down the pool gracefully.
If you're using JSP 1.1, I suggest you develop a set of custom
actions (e.g. <sql:query>, <sql:update> etc.) that you can use to
access the database from your JSP pages. A custom action handler is
always initalized with the pageContext object, which gives it access
to the ServletContext attributes. In JSP 1.0 you can do the same
with beans, but you need to provide it with a reference to the
ServletContext yourself, and you need scriptlets in the page to
call methods that access the database.
Another alternative is to use the MVC model, also referred to as "Model 2".
You then let a regular servlet do all database calls, put the result in a
bean and forward to a JSP for presentation. Search the list archives
for details. This approach has been discussed at length in other mails.
Hans
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
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