tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pykäläinen, Eero" <>
Subject Problem: JSP calls singleton. Singleton's data changes, but JSP s till shows old data from that singleton
Date Tue, 23 Apr 2002 11:34:26 GMT
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.


  ListOfAllComponents listOfAllComponents =
  // extracting data here...

Singeton class' getInstance() method:

public static synchronized ListOfAllComponents getInstance() {
  try {
    if ( _instance == null ) {
      _instance = new ListOfAllComponents();

    if ( upToDate == false ) {
      _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 Pykalainen, Software Developer, Yomi Solutions Ltd.

To unsubscribe:   <>
For additional commands: <>
Troubles with the list: <>

View raw message