This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Services and the fly likes Run Web Service Method Automatically on Tomcat 7.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Run Web Service Method Automatically on Tomcat 7.0" Watch "Run Web Service Method Automatically on Tomcat 7.0" New topic
Author

Run Web Service Method Automatically on Tomcat 7.0

Rami Kudmani
Greenhorn

Joined: Aug 13, 2011
Posts: 1
Dears,

1- I created a web service which I want it to run automatically when Tomcat starts. I want to know how I can do this in simple way (as i'm knew in Java development).
2- I want this web service's method to run periodically (every 30sec). What should I do to have this.

I'm using eclipse/Tomcat 7.0,

Appreciate your support as I'm still did not understand the concept of Servlet, and how to use my web service as a servlet. Or if I can't forget about web service and I need something else to have my above requests done.

Thank you,
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41150
    
  45
Web services are not meant to be executed periodically w/o client requests. You should create a pair of java.util.Timer and TimerTask in a ServletContextListener of your web app to do this.

The relationship between web services and servlets is only a loose one - Java webservice stacks are implemented using servlets, but that is hidden from the web service developer.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Run Web Service Method Automatically on Tomcat 7.0
 
Similar Threads
How to run an infinite loop in servlet
How to call service() from init()
Setting up contexts somewhere other than webapps
RMI server in servlet
Weblogic 7.0 and ActiveX