Scott,

You could obtain the parameters from within the
ServletContext.getInitParameter() method.  This can be accessed from an
Action or PlugIn class and stored by you.  Then, you could pull the values
into your ActionForm.  How could you store it?  In a JNDI context, in a
class, etc.

Inside a PlugIn.init() call (using the ActionServlet as arg0):
arg0.getServletContext().getInitParameter("PARAMNAME");

 Inside an Action.execute() call:
getServlet().getServletContext().getInitParameter("PARAMNAME");

If you still need to get it from an ActionForm, you can use the Commons
Digester to read the web.xml but you'd better store it because reading that
file each time an ActionForm needs to look things up will be excessive
input/output.  I've almost figured out how to use the Digester to read
values like param-name and param-value.

Regards,
David

-----Original Message-----
From: Scott Purcell [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 01, 2005 9:13 AM
To: user@struts.apache.org
Subject: How to get web.xml to ActionForm via struts?


Hello,

I have ran into a snag and I hope someone has an answer, or clue on this. I
am using a set of DatabasePooling classes to handle all my database needs. I
store the dbID in the web.xml file as a context-param.  Prior to using
Struts, I would create a bean using <jsp:useBean and since this was a bean,
I would just pass in the dbid at creation time. No big deal.

Now when I am using struts, I do not understand how to get the value into my
classes that extend ActionForm (my new beans).

I know this appears simple, but I am not using DynaAction forms, I am using
ActionForms. I see how the Dyna can take parameters, but I do not see that
for ActionForms. Also I do not want to duplicate the dbid connection string
and put it in the struts-config.xml file. I want to keep it in the web.xml
file.

Thanks,
Scott




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

Reply via email to