Using the function storeSessionId() , I retrieved the value of storedSession and assigned to sessionId from the servlet using AJAX.
var storedSession;
var sessionId;
function storeSessionId(){
try
{
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
storedSession = xmlhttp.responseText.toString();
sessionIdValue(storedSession);
}
};
xmlhttp.open("POST","JoinAction?subject="+subject+"&userId="+userId+"&secureKey="+secureKey,true);
xmlhttp.send();
}
catch(err)
{
alert(err.description);
}
}
When I compared the sessionId!=null only my div will be displayed else it cannot be displayed.
But even if I got sessionId==null also, my div was displayed. My div was displayed in both the condition.
function sessionIdValue(storedSession){
sessionId = storedSession;
if(sessionId != null && sessionId != "null"){
document.getElementById("div").style.display="inline";
}
}
The solution is ,
I passed the sessionId value in to trim()…
Thanks for all who helped me..