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.x/docs/struts-defaultxml.html Another thing you can do is call the static method ServletActionContext.getServletContext() but this would be harder to support in a unit testing environment. If you implement ServletContextAware, then you could provide a mock ServletContext implementation in your unit test setup, while you'd have a lot more awkward setup to do to make sure that ServletActionContext.getServletContext was prepared to return a usable value. Joe On 1/31/07, Nagraj Rao <[EMAIL PROTECTED]> wrote:
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" <user@struts.apache.org> Sent: Wednesday, January 31, 2007 4:55 PM Subject: [s2] getting servletContext in actions > Hi, > If i need to get a servletContext object in my action class, is > implementing the ServletContextAware interface the standard way of doing > this? Is there any other alternatives? > > thanks, > > Jeff > > --------------------------------------------------------------------- > 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]
-- Joe Germuska [EMAIL PROTECTED] * http://blog.germuska.com "The truth is that we learned from João forever to be out of tune." -- Caetano Veloso