Session variables with Ajax



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
.



Relevant Pages

  • Re: Any good URL about Java and AJAX?
    ... > AJAX + JSP, JSF, EJB, Hibernate, SOA, etc. - anything!!!! ... Why do you want to mix Java into it? ... the vouge is to use the XmlHttpObject supported by most modern browsers. ... a .jsp or servlet that respond to the AJAX call from the browser. ...
    (comp.lang.java.programmer)
  • Re: Any good URL about Java and AJAX?
    ... > Do you know for any good URL, portal, forum, newsgroup, yahoo ... > AJAX + JSP, JSF, EJB, Hibernate, SOA, etc. - anything!!!! ... * Looking for Java or PB code examples? ...
    (comp.lang.java.programmer)
  • Books - Sun Java Web component developer certification
    ... form parameters from the request, ... Section 4: Session Management ... The JavaServer Pages (JSP) Technology Model ... Building JSP Pages Using Tag Libraries ...
    (comp.lang.java.programmer)
  • Java / J2EE Interview questions
    ... Core Java and OOP's Interview questions ... Servlets / JSP Interview questions ... What’s an interface and how will you go about implementing an ... Servlets and JSP ...
    (comp.lang.java.gui)
  • Re: Discussion: PHP versus JSP
    ... We used MySQL, Tomcat, and JSP. ... > re-doing the app using PHP. ... JSP is an attempt from the Java camp to achieve an ASP/PHP like programming ...
    (comp.lang.java)