Order the Book

coreservlets
Class ConnectionPoolServlet

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--coreservlets.ConnectionPoolServlet
Direct Known Subclasses:
ConnectionPoolServlet2

public class ConnectionPoolServlet
extends HttpServlet

A servlet that reads information from a database and presents it in an HTML table. It uses connection pooling to optimize the database retrieval. A good test case is ConnectionPool.html, which loads many copies of this servlet into different frame cells.

Taken from Core Servlets and JavaServer Pages from Prentice Hall and Sun Microsystems Press, http://www.coreservlets.com/. © 2000 Marty Hall; may be freely used or adapted.

See Also:
Serialized Form

Constructor Summary
ConnectionPoolServlet()
           
 
Method Summary
 void destroy()
           
 void doGet(HttpServletRequest request, HttpServletResponse response)
           
 void init()
          Initialize the connection pool when servlet is initialized.
protected  int initialConnections()
          Override this in subclass to change number of initial connections.
protected  int maxConnections()
          Override this in subclass to change maximum number of connections.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doOptions, doPost, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionPoolServlet

public ConnectionPoolServlet()
Method Detail

doGet

public void doGet(HttpServletRequest request,
                  HttpServletResponse response)
           throws ServletException,
                  IOException
Overrides:
doGet in class HttpServlet

init

public void init()
Initialize the connection pool when servlet is initialized. To avoid a delay on first access, load the servlet ahead of time yourself or have the server automatically load it after reboot.
Overrides:
init in class GenericServlet

destroy

public void destroy()
Overrides:
destroy in class GenericServlet

initialConnections

protected int initialConnections()
Override this in subclass to change number of initial connections.

maxConnections

protected int maxConnections()
Override this in subclass to change maximum number of connections.

Order the Book

Order
CSAJSP @ amazon.com

Return to Top-Level Source Code Archive