struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonas Bjornerstedt <jo...@bjornerstedt.org>
Subject RE: How to put things in the ServletContext
Date Tue, 20 Aug 2002 18:39:58 GMT
Given the recent discussion of Struts and connection pooling, it might be a
good idea to include a connection pool example as an application.

Jonas

> -----Original Message-----
> From: Craig R. McClanahan [mailto:craigmcc@apache.org]
> Sent: den 20 augusti 2002 20:24
> To: Struts Users Mailing List
> Subject: RE: How to put things in the ServletContext
>
>
>
>
> On Tue, 20 Aug 2002, Robert Taylor wrote:
>
> > Date: Tue, 20 Aug 2002 05:33:09 -0400
> > From: Robert Taylor <rtaylor@mulework.com>
> > Reply-To: Struts Users Mailing List <struts-user@jakarta.apache.org>
> > To: Struts Users Mailing List <struts-user@jakarta.apache.org>
> > Subject: RE: How to put things in the ServletContext
> >
> > Adam, take a look at javax.servlet.ServletContextListener. You
> have access
> > to ServletContext via the ServletContextEvent in contextInitialized().
> >
>
> ServletContextListener is designed for exactly this sort of thing, but
> requires a Servlet 2.3 container.  If you're stuck on 2.2, Struts 1.1
> includes a new PlugIn facility that is designed to "plug things in" to the
> init() and destroy() methods without having to subclass ActionServlet.
>
> The Struts example app in 1.1 demonstrates how the API is used, by using a
> plugin to load its pseudo-database.
>
> Craig
>
>
> >
> >
> >      /**
> > 	 * Called just after the web application has been initialized
> > 	 *
> > 	 * @param event the ServletContextEvent containing the
> ServletContext
> > 	 */
> > 	public void contextInitialized(ServletContextEvent event) {
> >
> > 		ServletContext context = event.getServletContext();
> > 		Object o = //get home interface
> >
> >
> > 		context.setAttribute("someName", o);
> >
> >             // other stuff here
> > 	}
> >
> >
> > HTH,
> >
> > robert
> >
> >
> > > -----Original Message-----
> > > From: Adam Connors [mailto:adam.connors@cognima.com]
> > > Sent: Tuesday, August 20, 2002 5:16 AM
> > > To: struts-user@jakarta.apache.org
> > > Subject: How to put things in the ServletContext
> > >
> > >
> > > Hello,
> > >
> > > Apologies if this is an obvious one I've missed, (I'm a newbie
> > > and a bit bewildered by the onslaught of new information). But I
> > > want to put the home interface for an ejb into the servlet
> > > context to save time with multiple jndi lookups.
> > >
> > > Traditionally this is easily done in the servlet init() method
> > > and by making it a static member of the servlet. But I don't have
> > > access to this anymore since everything goes through the
> action servlet.
> > >
> > > Is there a way of putting stuff into the init() method of the
> > > action servlet without faffing around with subclassing it?
> > >
> > > I've found the DataSource and connection pool stuff, is this what
> > > I need? Can I have application context without the pool? Would
> > > there be any consequences of creating a pool with just one entry?
> > >
> > > Many thanks for your help,
> > >
> > > Adam.
> > >
> > > --
> > > To unsubscribe, e-mail:
> > > <mailto:struts-user-unsubscribe@jakarta.apache.org>
> > > For additional commands, e-mail:
> > > <mailto:struts-user-help@jakarta.apache.org>
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:struts-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> <mailto:struts-user-help@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
> <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:struts-user-help@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message