Hi all, My problem with cookies are in following I'm try to add new cookie and few lines after I'm going to read all cookies and to make new object and to assign it to Spring View, problem is that mine cookies are not added, everything works after page reload but not in same time...
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
if (cookies[i].getName().equals(
"proizvod_" + Integer.toString(proizvodiId))) {
String kolicina_cur = cookies[i].getValue();
int pom = Integer.parseInt(kolicina_cur);
cookies[i].setValue(Integer.toString(pom + kolicina));
response.addCookie(cookies[i]);
}
}
}
Cookie[] cookiesN = request.getCookies();
ProizvodiCommand proizvodiCommand = new ProizvodiCommand();
if (cookiesN != null) {
for (int i = 0; i < cookiesN.length; i++) {
if (cookiesN[i].getName().startsWith("proizvod_")) {
String ime = cookiesN[i].getName();
String kolicinaN = cookiesN[i].getValue();
String id_s = ime.replace("proizvod_", "");
int id = Integer.parseInt(id_s);
// prepare for spring view....
}
}
}
I was remove few lines for spring data preparation, for better view.
Same problem occurs when I try to remove cookie and to collect all existing cookies few lines below, it works after page reload.
I was try to add some delay, but not helps...If someone have a solution go ahead and share it with me :)
Thanks!