• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

scheduling JSF application

 
Sonal Sharma
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How should I schedule my JSF application that it fetches the data from the file and upload it in database after every 3 mins.I am using Netbeans with Visual Web Pack.

--Sonal
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18282
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSF - or for that matter, any J2EE webapp - isn't a "program" that runs. It's an architecture that sits idle until someone makes an HTTP request, whereon it invokes the appropriate application logic and sends a response. At which time it sits idle again until the next request.

There are certain circumstances where a traditional program may be integrated into a webapp, and they are done by spawning threads (typically in a servlet's init() method). But this probably isn't one of them.

If you were hoping to dynamically refresh a page display from a database, it wouldn't help. A web page cannot be "pushed", it can only be "pulled", so you'd need to have the user bring up a web page with some sort of refresh option on it (which causes their browser to send another page request after an interval has expired).

How you update the server's view of the database is another matter. Although a page refresh could get an update database view by counting the time since the last database fetch was done, that may be over-complicating things. In modern-day databases and persistency architectures, often less work will do more for you. By which I mean that instead of attempting to do timed data refreshes, simply make a database query on each page request.

If you are using a sufficiently advanced persistency mechanism, the system will optimize the request such that actual data transfer is only done when the database has changed. You'll get more efficient use of your resources and your code will be less complicated.

Since this can vary depending on what you're working with, it's a good idea to do it the simple way at first and then try optimizing it if/as needed.
 
Sonal Sharma
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"By which I mean that instead of attempting to do timed data refreshes, simply make a database query on each page request."

There is only one page which is fetching the data from the database after every 5 mins. Please give some code snippet so that I can show the real time report to the user. The database is being updated every 2 mins.

Thanks and regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic