• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

scheduling JSF application

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic