Try using the below mentioned code to read intialization parameter
defined in the Web descriptor file.

String sname = servlet.getInitParameter("myParamName");
 
           OR

ServletConfig config = servlet.getServletConfig();
String sname = config.getInitParameter("myParamName");

'servlet' is a field defined in Action class, so it can be used in your action class. 
It returns the controller servlet instance (i.e instance of the ActionServlet ) to 
which 
the Action clas is attached to.

Regards,
Ashutosh
        
-----Original Message-----
From: Frank Burns [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 20, 2004 8:59 AM
To: Struts Users Mailing List
Subject: Re: How to read a parameter in web.xml from Action class


Sorry, see my CORRECTION below:

----- Original Message ----- 
From: "Frank Burns" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Thursday, May 20, 2004 4:19 AM
Subject: How to read a parameter in web.xml from Action class


> Hi,
>
> From an Action class, I want to read a parameter specified in the web.xml
> file. I thought I could place it in an <init-param> block, within the
> <servlet-name>action</servlet-name> element, like this:
>
>     <init-param>
>       <param-name>myParamName</param-name>
>       <param-value>myParamValue</param-value>
>     </init-param>
>
> and then read it within the Action class using:
>
>     String paramValue =
> request.getSession().getServletContext().getInitParameter("myParamValue");


CORRECTION:
request.getSession().getServletContext().getInitParameter("myParamName");

>
> But I get null.
>
> What am I doing wrong?
>
> Thanks,
>
> Frank.
>
>
> ---------------------------------------------------------------------
> 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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to