wood burning stoves*
The moose likes Struts and the fly likes Can I access the Application Context from a Struts 2 Action? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Can I access the Application Context from a Struts 2 Action?" Watch "Can I access the Application Context from a Struts 2 Action?" New topic
Author

Can I access the Application Context from a Struts 2 Action?

Robert Heath
Ranch Hand

Joined: Aug 11, 2010
Posts: 94

I have looked at the ActionSupport class and there does not appear to be any way to get to the Application Context. for objects on the Application Context. Would it be a violation of best practices to access the Application Context from an action?
Jesus Mireles
Ranch Hand

Joined: Mar 10, 2010
Posts: 122

I think it depends what your getting the context for ...
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
If you use the Servlet Config Interceptor you can set up an application Map that can be accessed by all of your action classes that implement ApplicationAware. The same interceptor should also allow you to implement ServletContextAware interface to give you access to the servlet context if thats what you need.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can I access the Application Context from a Struts 2 Action?
 
Similar Threads
Communication Between 2 Action Classes
How to set a html:text value equal to an expression? (SOLVED)
getting stuff out of action classes and into the application scope of a jsp?
Accessing servlet
Accessing a servlet from a Struts App running in another context.