wood burning stoves*
The moose likes Struts and the fly likes Run an action servlet upon startup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Run an action servlet upon startup" Watch "Run an action servlet upon startup" New topic
Author

Run an action servlet upon startup

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Hi,

I'm using Struts 1.3. I have this action servlet defined in my struts-config.xml file ...

<action path="/refresh"
type="com.myco.regui.struts.refresh.RefreshAction"
scope="request"
validate="false">
</action>

The servlet takes no request parameters. How can I invoke the servlet automatically upon application startup? - Dave
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

App startup duties are generally handled by servlets or a plugin; is there any particular reason it needs to be an action?
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Just code-reuse. I wanted to call an action -- /<ctx>/refresh.do an arbitrary points during my app's life cycle, but I also wanted to invoke the same functionality immediately upon application startup. I could also create a servlet and start it up in web.xml, but then I have two code bases that essentially do the same thing, so I was wondering if there was a way to merge the two.

- Dave
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Whatever the action's logic is should be encapsulated in business logic anyway, no? If it's not web-related it doesn't belong in an action, IMO, although the web tier can *call* it.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Run an action servlet upon startup