struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Jesse <alexander.je...@csfs.com>
Subject RE: properties file in action class
Date Thu, 15 Nov 2001 08:56:14 GMT
In your first mail you write that you want to do it in ActionServlet...
then you must extend it...

In your action-class you could define a static property object, which
you lazy-initialize. When you need it, check for a null-value. If null:
read the property-file and populate the propety-object; if not null:
just use it.

hope this helps
Alexander

-----Original Message-----
From: ADua@wellington.com [mailto:ADua@wellington.com]
Sent: Wednesday, November 14, 2001 9:47 PM
To: struts-user@jakarta.apache.org
Subject: RE: properties file in action class


but if I do not want to subclass ActionServlet

-----Original Message-----
From: Sobkowski, Andrej [mailto:Andrej.Sobkowski@emergis.com]
Sent: Wednesday, November 14, 2001 3:19 PM
To: 'Struts Users Mailing List'
Subject: RE: properties file in action class


Hello,

I guess you could subclass ActionServlet and overwrite an existing initABC()
method:

public class MyActionServlet extends ActionServlet {
  ...
  protected void initOther throws ServletException {
    super.initOther(); // don't forget this one.. :)
    myInit();
  }

  protected void myInit() {
    // Add here your servlet's init code and make it available 
    // to your actions.
  }
}

Just an idea...

Andrej

PS. You'll also have to change the struts-config.xml to point to your
MyActionServlet.

-----Original Message-----
From: Dua, Amit [mailto:ADua@wellington.com]
Sent: Wednesday, November 14, 2001 3:11 PM
To: 'Struts Users Mailing List'
Subject: properties file in action class



Hi
 if  I have to load a properties file in my action class.
I can do it in perform method.
But  I want to do it in init of Action Servlet , so that it does not get
loaded every time a call is made to the action class.How can I do this.

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

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

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


Mime
View raw message