How to get data from database in the begining
Hi
I am using JSF + some DB in my project. I am trying to do more than just a web app. I can get the page data from the database at any time because user would click on it.
What I want to do is, At the start of the tomcat server, I would like to fetch some data and send the data to some other processes. What are the best ways to do that?
Do I need need to write a servlet and write just the init method ?
at the same time, the JSF application should also use the same connection to update any page date.
thanks
[550 byte] By [
vpalkondaa] at [2007-11-26 21:48:44]

# 1
You could use the load-on-startup tag in your project's web.xml , to start the Servlet that loads all the initial data from the database.
This explains load-on-startup
http://mail-archives.apache.org/mod_mbox/struts-user/200312.mbox/%3C02a401c3b987$c3b701a0$65fea8c0@kurtosys%3E
Say the Servlet loads data into a JavaBean or a list of JavaBeans, then other classes could read from the JavaBean or list of JavaBeans loaded by the Servlet.
I've just begun learning JSF so I can't really help with the JSF part.
# 5
thanks for the link.
But the problem is the backing bean gets invoked only when the user does something on JSF pages.
But my problem is what if the user does not bring the up th web page.
I want to retrieve the data when the tomcat starts and send it over to some other process like when booting a device....
The only thing the JSF servlet starts when the tomcat starts. But I cannot init in the JSF servlet. I was wondering if there is any way that servlet notifies an object when it starts. So that I can init the data