You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Scott Purcell <sp...@vertisinc.com> on 2005/03/01 17:08:59 UTC

Need Help Passing Data Values To My subclass Action class

I am trying to pass a value that is configured in my web.xml which is my "databaseID" that I need in my Action class.
 
I have asked prior, but received no help, so I am trying again. If I have a value in the deployment file that I can get out using a ServletContext, how can I get that into a subclass of an Action class, or even to a ActionForm subclass, since neither extend the HttpServlet class?
 
I would appreciate any input,
Sincerely
Scott
 
 
 

AW: Need Help Passing Data Values To My subclass Action class

Posted by Günther Wieser <gw...@creative-it.com>.
use request.getSession().getServletContext() in the action class to receive
the context of the struts action servlet, and you can use the action class
to set a property of the action form as you would do it if you want to
prepopulate form data (a good example is described in
http://www.javaworld.com/javaworld/jw-09-2004/jw-0913-struts-p3.html using
two action classes, one for prepopulating the action form and one for the
actual "doing").
also you could implement a class that gets initialized during loading of a
webapp (e.g. implementing ServletContextListener ) and gets all data from
servlet context into a hashmap, and have a static method that retrieves the
data from this hash map.

kr,
guenther

-----Ursprüngliche Nachricht-----
Von: Scott Purcell [mailto:spurcell@vertisinc.com] 
Gesendet: Dienstag, 01. März 2005 17:09
An: user@struts.apache.org
Betreff: Need Help Passing Data Values To My subclass Action class

I am trying to pass a value that is configured in my web.xml which is my
"databaseID" that I need in my Action class.
 
I have asked prior, but received no help, so I am trying again. If I have a
value in the deployment file that I can get out using a ServletContext, how
can I get that into a subclass of an Action class, or even to a ActionForm
subclass, since neither extend the HttpServlet class?
 
I would appreciate any input,
Sincerely
Scott
 
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org