Session variables with Ajax
- From: "soup_or_power@xxxxxxxxx" <soup_or_power@xxxxxxxxx>
- Date: Fri, 31 Oct 2008 08:10:22 -0700 (PDT)
Hi All
I use Ajax to call a JSP page that is heavy duty. After the JSP gets
done it will set a session variable as session.setAttribute("flag",
"1"). I read the session from Java and process it as follows:
try {
for (;;) {
Map m=
FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
String flag=(String)m.get("pushsession1");
System.out.println("flag=" + flag);
if (flag == null || flag.trim().equals("")){
Thread.sleep(2000);
logger.debug("waiting for pushsession1");
System.out.println("waiting for pushsession1");
}
else {
m.put("pushsession1", "");
System.out.println("done pushsession1");
logger.debug("done pushsession1");
break;
}
}
} catch (Exception e) {};
I expect the java method to wait until the JSP gets done. What I am
seeing is the session in Java sometimes gets the correct value for
flag and some times gets null for the flag. Could someone please
clarify how to integrate JSP with Java using Ajax?
I tried using the volatile for flag as : volatile String flag=... and
got compiler error.
Thanks
.
- Prev by Date: Re: Adding same elements in an array.,
- Next by Date: Re: how to insert space in a string
- Previous by thread: how to insert space in a string
- Next by thread: Java/TomCat How to Configure a Servlet contextPath
- Index(es):
Relevant Pages
|