You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Crazy Dave <mu...@yahoo.com> on 2002/02/20 13:09:41 UTC

(StrutsNewUser) - Accessing datasource in an initialisation servlet.

Web.xml extract
<!-- Application Initialization Servlet -->
<servlet>
<servlet-name>applicationInitialisation</servlet-name>
<servlet-class>Blah.ApplicationInitServlet</servlet-class>
<load-on-startup>3</load-on-startup>
</servlet>

I wish to load information into an arraylist of beans
for use in <html:select>, the data comes from
database.

I need to know how to get access to the datasource in
a standard servlet.

I've tried extending my class from ActionServlet, but
the datasource keeps returning null.

see below:

ServletContext sc = getServletContext( );
DataSource ds = findDataSource( null );

try {
SecurityModuleSql sql = new SecurityModuleSql( ds );
sc.setAttribute(key, sql.getDropDown( ) );
} 

Cheers Dave

__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>