You can do similar things in Actions, to a degree... you an do...

String myParamValue = getServlet().getInitParameter("myParamName");

...to get the parameter from within execute().

If you are looking to read things like this only once at startup, you want
to look at a Struts plug-in or, probably better, a context listener.

I think, generally-speaking, people tend to put their application-specific
configuration information into an external file (be it XML or properties,
or something else) and read it in on app startup in one of the two ways I
mentioned.

If you want to go the listener route (which I recommend because its more
portable, i.e., not Struts-specific), have a look at the
AppConfigContextListener component of my Java Web Parts project
(http://javawebparts.sf.net).  Even if you don't use it specifically, it
should serve as a good reference for a context listener.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Fri, July 8, 2005 12:25 pm, Abdullah Jibaly said:
> Why not put it them in your properties file?
>
> -----Original Message-----
> From: Tony Smith [mailto:[EMAIL PROTECTED]
> Sent: Friday, July 08, 2005 10:30 AM
> To: Struts Users Mailing List
> Subject: read init parameters in action
>
>
> For traditional servlets, you can set init parameters
> in the web.xml and read it in a static init method in
> servlet class. Can I have similar things for action?
> If I need some of these init parameter for my web app,
> what is the best way to do it with struts?
>
> Thansk,
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> 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