When an Action instance is first created, the controller servlet will call setServlet() with a non-null argument to identify the controller servlet instance to which this Action is attached.
So, the code inside an Action's constructor is executed before this happens. I personally don't know if there's a better way to do what you're trying to do. Why don't you like the way it's currently being done?
-Ben
From: "Shakti" <[EMAIL PROTECTED]> Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> CC: <[EMAIL PROTECTED]> Subject: Help Req : Loading init params Date: Fri, 12 Dec 2003 19:01:24 +0530
Hi All,
We are using weblogic7.1 struts 1.0 version.We are storing all application specific parameters in web.xml file.Hence in order to get that value we use following code in each action class :
getServlet().getInitParameter("INIT_PARAM")
Instead of this what I thought is we can have a common Parent action class which would load all this paramters and store them as it's attributes.
eg.
public class ParentAction extends DispatchAction { protected String INIT_PARAM = ""; public ParentAction () { INIT_PARAM = getServlet().getInitParameter("INIT_PARAM"); } }
Other action classes would extend this class instead of extending DispathAction class directly.
But when I try to get the value of init param in subclasses of parent action class it gives me an error.
public class LoginAction extends ParentAction
{
public ActionForward log(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception, IOException, ServletException {
System.out.println(INIT_PARAM); //gives NullPointerException
}
}
I would like to know whether above logic is valid if no is there any other workaround?
Regards, Shakti
_________________________________________________________________
Winterize your home with tips from MSN House & Home. http://special.msn.com/home/warmhome.armx
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]