hi all,
to my webapp named mrf, i have added load-on-startup tag
to mrf\WEB-INF\web.xml
so i added a snippet like so
<servlet>
<servlet-name>loadDbProp erties</servlet-name>
<servlet-class>mrf.LoadD bPropertiesServ let</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
this servlet just initalizes a connecion pool
*************** *************** ***
public class LoadDbPropertie sServlet extends HttpServlet {
public static Properties dbProperties;
public void init() throws ServletExceptio n
{
ConnectionPool connPool =
(ConnectionPool )getServletCont ext().
getAttribute("C ONNECTION_POOL" );
if (connPool==null )
{
ServletContext sc =
getServletConfi g().getServletC ontext();
try {
dbProperties.lo ad(sc.getResour ceAsStream("/WEB-INF/properties/db.properties") );
connPool =
new ConnectionPool( (String)dbPrope rties.get("dbdr iver"),
(String)dbPrope rties.get("dbur l"),
(String)dbPrope rties.get("user "),
(String)dbPrope rties.get"passw ord"),
Integer.parseIn t((String)dbPro perties.get("in itconns")),
Integer.parseIn t((String)dbPro perties.get("ma xconns")),
true);
getServletConte xt().setAttribu te("CONNECTION_ POOL",connPool) ;
}catch(Exceptio n ioe){ioe.printS tackTrace();}
}
}
}
*************** *************** *************
(also tried to put it in tomcat\conf\web .xml but still it does not
load on startup)
why the heck does this not load on startup? i looked for messages on
the groups but still unsure what i am doing wrong
thaks for any insight
to my webapp named mrf, i have added load-on-startup tag
to mrf\WEB-INF\web.xml
so i added a snippet like so
<servlet>
<servlet-name>loadDbProp erties</servlet-name>
<servlet-class>mrf.LoadD bPropertiesServ let</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
this servlet just initalizes a connecion pool
*************** *************** ***
public class LoadDbPropertie sServlet extends HttpServlet {
public static Properties dbProperties;
public void init() throws ServletExceptio n
{
ConnectionPool connPool =
(ConnectionPool )getServletCont ext().
getAttribute("C ONNECTION_POOL" );
if (connPool==null )
{
ServletContext sc =
getServletConfi g().getServletC ontext();
try {
dbProperties.lo ad(sc.getResour ceAsStream("/WEB-INF/properties/db.properties") );
connPool =
new ConnectionPool( (String)dbPrope rties.get("dbdr iver"),
(String)dbPrope rties.get("dbur l"),
(String)dbPrope rties.get("user "),
(String)dbPrope rties.get"passw ord"),
Integer.parseIn t((String)dbPro perties.get("in itconns")),
Integer.parseIn t((String)dbPro perties.get("ma xconns")),
true);
getServletConte xt().setAttribu te("CONNECTION_ POOL",connPool) ;
}catch(Exceptio n ioe){ioe.printS tackTrace();}
}
}
}
*************** *************** *************
(also tried to put it in tomcat\conf\web .xml but still it does not
load on startup)
why the heck does this not load on startup? i looked for messages on
the groups but still unsure what i am doing wrong
thaks for any insight
Comment