Two Laptop Bag*
The moose likes Beginning Java and the fly likes Can a servlet perform an action at intervals Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can a servlet perform an action at intervals" Watch "Can a servlet perform an action at intervals" New topic
Author

Can a servlet perform an action at intervals

Steve Cannon
Greenhorn

Joined: Jan 17, 2003
Posts: 8
I am designing a domino application which will be taking data and writing it to an Oracle database.
In one of the design meetings, we decided to look at using a servlet to do the connection to the domino database and, if there were new documents to post, send the data to the Oracle database via JDBC.
Is it possible to have a servlet running which would check a domino database every say, 5 min or 20 min and, if necessary, write data to Oracle?
If so, can you point me in a direction as to how I should approach coding this? My other option would be to use a scheduled domino agent to connect using ODBC, but I was thinking that the servlet would be less resource intensive since it's always loaded.
Since it's domino, I'm restricted to 1.18 JVM.
Thanks in advance.
Steve
Matt O'Toole
Greenhorn

Joined: Feb 02, 2002
Posts: 23
What first comes to my mind is to do your procedure in a thread, and call Thread.sleep() with the appropriate interval.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

From what I have heard, spawning threads in a Servlet is never a good idea.
My advice would be to create a stand alone program on the Server (or somewhere) that performs your operation. Do not do it in a servlet.
Is there any particular reason you wanted to use a servlet?
You may get better responses in the Servlet forum if a Bartender would be so kind as to move this.


GenRocket - Experts at Building Test Data
Steve Cannon
Greenhorn

Joined: Jan 17, 2003
Posts: 8
Thanks to both of you for your reply.
I had thought about a stand alone program and that may be the way to go. I'm still learning Java so I didn't know all the options to consider. Also, my reason for posting in this forum was that it seemed like a pretty beginner type of question.
One thing I was thinking about was submitting to the servlet. If I did a post to the servlet, it could connect to the Oracle database and write the data as well. This way, I wouldn't have to be worrying about having the servlet or program constantly checking the database. There might be some other issues to contend with if I do that though.
Would doing a post to a servlet be a better idea or do you think a stand alone Java program would work better?
Thanks in advance for your reply.
Steve
 
Consider Paul's rocket mass heater.
 
subject: Can a servlet perform an action at intervals