You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Filipe David Manana <fd...@ieee.org> on 2008/01/10 23:55:13 UTC

Struts 2 and Container resources

Hi,

How can I access a Container's resource within the code of an action?

cheers

-- 
Filipe David Manana,
fdmanana@ieee.org

Obvious facts are like secrets to those not trained to see them.

Re: Struts 2 and Container resources

Posted by Ted Husted <hu...@apache.org>.
The container's resources can be access from an Action via the
HttpServletRequest object.

To obtain the HttpServletRequest object, see

 * http://struts.apache.org/2.x/docs/how-can-we-access-the-httpservletrequest.html

HTH, Ted
 * <http://www.StrutsMentor.com/>


On Jan 10, 2008 5:55 PM, Filipe David Manana <fd...@ieee.org> wrote:
> Hi,
>
> How can I access a Container's resource within the code of an action?
>
> cheers
>
> --
> Filipe David Manana,
> fdmanana@ieee.org
>
> Obvious facts are like secrets to those not trained to see them.

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


Re: Struts 2 and Container resources

Posted by Don Brown <do...@gmail.com>.
Do you want a bean from the Container?  If so, just put an @Inject
annotation above a setter.  For example, to get the ObjectFactory, put
this code in your Action:

@Inject
public void setObjectFactory(ObjectFactory factory) {
  this.objectFactory = factory;
}

Since Actions, Results, and Interceptors are automatically processed
for injections, you have access to any internal Struts component (or
configuration setting) in the container.

Don

On Jan 11, 2008 9:55 AM, Filipe David Manana <fd...@ieee.org> wrote:
> Hi,
>
> How can I access a Container's resource within the code of an action?
>
> cheers
>
> --
> Filipe David Manana,
> fdmanana@ieee.org
>
> Obvious facts are like secrets to those not trained to see them.
>

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