I am using Tomcat 4.0.4-b1 (and Struts 1.0.2) on W2K.
I have a singleton class that keeps data inside of it.
I have a JSP page that calls the singleton.
When singleton's data is up-to-date, JSP page opens quickly. When it isn't,
singleton updates its data structure from database and then JSP shows up.
There is only one problem: although singleton updates itself, singleton's
changed data isn't visible in the JSP page. It still shows old data.
JSP:
<%
ListOfAllComponents listOfAllComponents =
ListOfAllComponents.getInstance();
// extracting data here...
%>
Singeton class' getInstance() method:
public static synchronized ListOfAllComponents getInstance() {
try {
if ( _instance == null ) {
_instance = new ListOfAllComponents();
}
if ( upToDate == false ) {
_instance.getListOfAllComponents();
_instance.log("Refreshed listOfAllComponents");
upToDate = true;
}
} catch ( Throwable e ) {
e.printStackTrace( System.out );
}
return _instance;
}
I call my log method inside the getListOfAllComponents() method so I *know*
that the data is changed.
My workflow:
1) I call the JSP page that shows data from singleton
2) I call another JSP page that changes the upToDate boolean flag
3) I call the JSP page that shows data from singleton. At this phase the log
method inside getListOfAllComponents method logs the *updated* data to my
log file
4) JSP page shows up. It still shows the old data.
Am I doing something wrong or missing something here?
Thank you very much of your help,
Eero
--
Eero Pykalainen, Software Developer, Yomi Solutions Ltd.
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>