I've searched jquery forum, stackoverflow, google, bing, and even yahoo w/o success. Every 10 sec I'm trying to load a text data from logservlet servlet via this JQuery snippet:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
var autorefresh = setInterval(function () {
$.ajax({
url : "logservlet?devkey=chat",
success : function(data) {
$("#log_ta").append(data);
}
});
}, 10000);
</script>
The problem is, on a server side I don't see a valid session where I try to track the session attributes. The problem seems to be related to missing "Cookie JSESSIONID=xxxxxxxxxxxxxxxxxxxxxxxxxxx" in the header of the http requests from JQuery. I'm getting response headers from the server, with JSESSIONID always changing with each request:
Server Apache-Coyote/1.1
Set-Cookie JSESSIONID=9EEAFA2A933E7742D8FEDADD5345B76D; Path=/CumulusServer
Content-Length 0
Date Fri, 23 Mar 2012 13:02:08 GMT
But JQuery doesn't use it subsequently, here are the request headers:
Host 192.168.1.11:8080
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0
Accept */*
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection keep-alive
X-Requested-With XMLHttpRequest
Referer http://192.168.1.11:8080//CumulusServer/
What's the issues here? Are "$.ajax" calls not session aware? Or do I miss some plumbing code to hardcode the JSESSIONID manually in each ajax request? Is so, how this should look like? Btw, when I call the same url from web browser the JSESSIONID header is sent to the server!
Thanks, D.