tags:

views:

315

answers:

1

Hello guys!

I need to some properties such as init params to all my actions. How can I access init parameters in my action classes. Or is there any way such that I can pass parameters to my actions. I could use .properties file but that would be for only one action. I need to define parameters for all actions.

Thanks in advance

+1  A: 

Th ActionContext gives access to the ServletContext, that in turn gives access to init parameters defined in the Web Applications deployment decriptor.

Implication of passing parameters this way is that they are deployed in the app. Possibly you might prefer to take them from some externally, separately deployable source? In which case picking up a config file or reading from a database might give more flexibility.

This article describes an approach to externalising the config. It's clearly more work, and increased complexity, but I have found the flexibility to be useful.

djna
This will work for me. I think its better to externalize the properties as they might change a lot in future. Thanks for such a quick reply.
Zaheer Baloch