aspose file tools*
The moose likes Servlets and the fly likes Background stored procedure call Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Background stored procedure call" Watch "Background stored procedure call" New topic
Author

Background stored procedure call

sridhar lakka
Ranch Hand

Joined: Jan 02, 2007
Posts: 109
Hi All,
Thanks in advance.
I have a doubt/requirement that, we are using struts as a frame work in our web appllication,and there is one procedure which should be called for every 15 minutes to check some status of one column of table, and depending upon that i have to send some alert to the users.
I am not getting any idea how to do.
Please help me in, how to call a procedure at background and how to pass alert to all the users whoever are loggedin.

Please give me some example code also.

Regards,
Sree
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42263
    
  64
There are two parts to it, the periodic background task and the user notificasion.

The periodic task can be done by a java.util.Timer and TimerTask, which is essentially a thread that runs at certain prespecified times.

The user notification can only be done indirectly, since a web app can't call the web client directly. The background task might set a flag in the user session which signals that the next time this user accesses the web app, there should be some kind of notification at the top of the page. Alternatively, the background task could send an email to the user.


Ping & DNS - my free Android networking tools app
sridhar lakka
Ranch Hand

Joined: Jan 02, 2007
Posts: 109
Thanks a lot,
Please could you tell in detail, with some example code.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42263
    
  64
Well, we try to help people learn Java here, not provide them with solutions. So, what have you implemented so far? What specific questions do you have?

If you aren't familiar with Timer/TimerTask, read their javadocs and see if you can get them to work. The Java Almanac also has an example of their use.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

Originally posted by Ulf Dittmer:
There are two parts to it, the periodic background task and the user notificasion.

The periodic task can be done by a java.util.Timer and TimerTask, which is essentially a thread that runs at certain prespecified times.

The user notification can only be done indirectly, since a web app can't call the web client directly. The background task might set a flag in the user session which signals that the next time this user accesses the web app, there should be some kind of notification at the top of the page. Alternatively, the background task could send an email to the user.


That would be the way to go about it. You can alternatively use some kind of scheduler (Cron/ Weblogic scheduler etc etc whatever is available) to run code every X minutes.


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Background stored procedure call