Accessing <init-params>

Hi all,

I am working with a struts applications.

In theweb.xml i have kept some init parameters...

<init-param>

<param-name>Email</param-name>

<param-value>siva@ramnfsd.com</param-value>

</init-param>

<init-param>

<param-name>Phn</param-name>

<param-value>12345678</param-value>

</init-param>

I want to access them from strutsaction class.

Anybody Can u pls assist me?

If it is JSP/Servlet. I can do this simply..

emailHost = config.getInitParameter("emailHost");

But this is not working in structs.

Pls assist me.

Thakks in Advance.

Regards

Siva Prasad

[763 byte] By [NNVSivaPrasada] at [2007-11-26 15:48:12]
# 1
All you need to do is:getServletContext().getInitParameter("Email").toString();MeTitus
Me_Titusa at 2007-7-8 22:07:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
HiThanks for your mail.getServletContext() is not accessible from execute( ) methd of Strut's Action Class...What to do now ?Regards.Siva Prasad.
NNVSivaPrasada at 2007-7-8 22:07:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
I can't help you... as I have never worked with struts, but basically, if you are speaking about a normal class which doesn't extend the HttpServlet.. then perhaps you could pass to that class a reference of the request object.MeTitus
Me_Titusa at 2007-7-8 22:07:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

The "application" implicit variable defined in a JSP is of type ServletContext.

The most certain way to obtain it in a servlet is via the call

ServletContext application = getServletConfig().getServletContext();

When in Struts, you can get the Servlet via a call to getServlet().

ServletContext applciation = getServlet().getServletConfig().getServletContext();

evnafetsa at 2007-7-8 22:07:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...