The example application defines a custom plug-in that is initialised at
start-up and loads the database and stores it in the ServletContext
(application scope).

struts-config.xml:
  <plug-in
className="org.apache.struts.webapp.example.memory.MemoryDatabasePlugIn">
    <set-property property="pathname" value="/WEB-INF/database.xml"/>
  </plug-in>

MemoryDatabasePlugIn.java
  servlet.getServletContext().setAttribute(Constants.DATABASE_KEY,
database);

Constants.java
  public static final String DATABASE_KEY = "database";

Plug-ins are a common way to initialise application resources. Another way,
that requires at least a Servlet 2.3 container would be to implement a
ServletContextListener.

Steve

http://www.ninsky.com/struts/



> -----Original Message-----
> From: Derrick Brooks [mailto:[EMAIL PROTECTED]
> Sent: August 24, 2003 3:43 PM
> To: [EMAIL PROTECTED]
> Subject: Struts-example database
>
>
> I just downloaded struts 1.1 binary and loaded the struts-example into
> tomcat and it works fine.
>
> My question is I do not understand when and how the database is loaded in
> the index.jsp. There is a tag that reads:
>
> <logic:notPresent name="database" scope="application">
>
> But I do not see the "database" name in the struts-config or web.xml file.
> In the tour.htm file it talks about a DatabaseServlet that I can
> not seem to
> find (I guess it was takin out).
>
> Thanks for the help,
>
> Derrick
>
> (Sorry if this is the second time you received this message. I do
> not think
> my first post went through.)
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to