2008/7/8 Kleiderman, Matthew <[EMAIL PROTECTED]>: > Is there any way to inject beans defined in struts.xml with > scope=singleton into a Servlet so that it's available when the Servlet's > init method is called?
Did you really meant injecting a bean defined inside Spring's applicationContext.xml file with scope="singleton" into a Servlet? If so, the answer is yes: public void init(FilterConfig filterConfig) throws ServletException { ... ServletContext servletContext = filterConfig.getServletContext(); WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext); // set up an injected bean into application scope servletContext.setAttribute("mybean", context.getBean("aBean")); ... } Alternately, is there a way to access where > these instances are stored so I can get a reference to the instance? > > Thanks, > > Matt Kleiderman > > --------------------------------------------------------------------- > 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]