Re: [s2] getting servletContext in actions

2007-01-31 Thread Jeffrey Hau
hi Joe, Implementing the ResourceLoaderAware interface has solved my problem. many thanks! i havent tried to use ServletContextAware but I think it will work equally well. many thanks Jeff On 31 Jan 2007, at 16:38, Joe Germuska wrote: Jeff: I think there are a lot of possible routes,

Re: [s2] getting servletContext in actions

2007-01-31 Thread Joe Germuska
On 1/31/07, Tom Schneider <[EMAIL PROTECTED]> wrote: It would be very easy to create a Spring FactoryBean for this. In this case, couldn't one simply implement Spring's ServletContextAware interface? http://www.springframework.org/docs/api/org/springframework/web/context/ServletContextAware.

Re: [s2] getting servletContext in actions

2007-01-31 Thread Joe Germuska
Jeff: I think there are a lot of possible routes, but I'm not sure I understand your goal. Could you just have your service implement ResourceLoaderAware? If your Spring ApplicationContext is a WebApplicationContext (as it would be if set up by ContextLoaderListener), then the ResourceLoader wo

Re: [s2] getting servletContext in actions

2007-01-31 Thread Jeffrey Hau
Hi Tom, I have tried your suggestion, my applicationContex.xml is now defined as, method="getServletContext"/> class="org.springframework.web.context.support.ServletContextResource">

Re: [s2] getting servletContext in actions

2007-01-31 Thread Tom Schneider
It would be very easy to create a Spring FactoryBean for this. (Checkout the Spring Documentation if that doesn't make sense) Then, to access the servlet context, just do a: ServletContext servletContext = ServletActionContext.getServletContext(); The FactoryBean would allow you to use depen

Re: [s2] getting servletContext in actions

2007-01-31 Thread Jeffrey Hau
Hi Joe, Thanks for the helpful information. I am just wondering is it possible to get the ServletContext object in my spring applicationContext.xml? What i am trying to do now is to create a Resource object (ServletContextResource) and inject into a service class and then use this service

Re: [s2] getting servletContext in actions

2007-01-31 Thread Joe Germuska
You need to make sure that your action is passing through an interceptor-stack that includes ServletConfigInterceptor http://struts.apache.org/2.x/core/apidocs/org/apache/struts2/interceptor/ServletConfigInterceptor.html The struts-default package does include this. http://struts.apache.org/2.

Re: [s2] getting servletContext in actions

2007-01-31 Thread Nagraj Rao
were u actually able to get the servletContext Object thru servletContextAware?? I'd tried it but couldn't get it :( do we need to do any additional stuff for that?? - Original Message - From: "Jeffrey Hau" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" Sent: Wednesday, January 3