Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

struts servlet init

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have extended struts Actionservlet to myservlet class.

myservlet class init method two times called.i don't know why.

Please update your comments.

init method code

public void init() throws ServletException {
try {
/** Get the ServletContext * */
ServletContext servletContext = this.getServletContext();


/** Initialize the logger * */
loadInitLogging();

/** Initialize the PropertyFileReader * */
loadPropertyFileReader(servletContext);

/** Logs the JDBC information * */
displayJDBCInfo();

/** Loads the Master Table values * */
loadMasterTableValues();


/** This method tiggers 12 AM of everyday
* and reloads the master table values
*/
//TimerJob.invokeTimer();


} catch (Exception e) {
LOG.error("Unexcepted error occurred", e);
LOG.error(e.getMessage());
}

super.init();
}
[ July 10, 2007: Message edited by: prabakaran perumal ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving over to our Struts forum.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I personally prefer to keep this sort of application startup logic out of Struts altogether. I would suggest creating a single method/API/class (whichever best suits your needs) and then using a ServletContextFilter to run your initialization.

Take a look at ServletContextFilters here -

http://www.onjava.com/pub/a/onjava/2001/04/12/listeners.html
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Wes that it's just not not a good idea to override the ActionServlet for this type of initialization stuff.

I'd suggest you write a class that implements the org.apache.struts.action.Plugin interface and register it as a plugin in your struts-config.xml file. Anything you put in the implemetation of the init(..) method will be called by Struts ActionServlet when it ititializes.
reply
    Bookmark Topic Watch Topic
  • New Topic