Hi,
I am trying to use an approach underlined in the book 'Java Servlet
Programming' by
Jason Hunter to make two servlet share some data. I created a singleton
called
AgentData and then made each servlet keep a ref. to this object as follows:
Servlet A
AgentData d1 = AgentData.getInstance();
Servlet B
AgentData d1 = AgentData.getInstance();
In A I put some data into AgentData but when I take it out in B,
it is empty? Can someone help me or suggest some other approach.
AgentData is given below:
import java.util.*;
public class AgentData {
private AgentData(){agentList = new Hashtable();}
private static AgentData instance = null;
private Hashtable agentList = null;
synchronized public static AgentData getInstance()
{
if (instance == null)
instance = new AgentData();
return instance;
}
synchronized public Hashtable getAgentList()
{
return agentList;
}
synchronized public void putAgentList(Hashtable h)
{
agentList = h;
}
}
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html