Hallo Zusammen,
ich habe eine Klasse, die Inhalte in einer HashMap speichert. Beim nächsten Zugriff aus meinem Servlet heraus auf diese Klasse, ist die HashMap leer.
Die Ausgabe sieht so aus:
### REPORT mapSize before save: 0
7L6b0iNr-FoDa-r5r1-G0IL-zjIFZZ287N4e=[fj4hdzr5, dh47dh4g]
### REPORT mapSize: 1
ich habe eine Klasse, die Inhalte in einer HashMap speichert. Beim nächsten Zugriff aus meinem Servlet heraus auf diese Klasse, ist die HashMap leer.
Java:
public class Report {
HashMap<String, ArrayList<String>> reportMap = new HashMap<String, ArrayList<String>>();
public void saveRowToMap(String id, String var1, String var2) {
int mapSize = reportMap.size();
System.out.println("### REPORT mapSize before save: " + mapSize);
ArrayList<String> reportRowArrayList = new ArrayList<String>();
reportRowArrayList.add(var1);
reportRowArrayList.add(var2);
reportMap.put(id, reportRowArrayList);
for ( Map.Entry<String, ArrayList<String>> e : reportMap.entrySet() ) {
System.out.println( e.getKey() + "="+ e.getValue() );
}
mapSize = reportMap.size();
System.out.println("### REPORT mapSize: " + mapSize);
}
}
Die Ausgabe sieht so aus:
### REPORT mapSize before save: 0
7L6b0iNr-FoDa-r5r1-G0IL-zjIFZZ287N4e=[fj4hdzr5, dh47dh4g]
### REPORT mapSize: 1