JQuery jsession cookie not sent to server

I searched the jquery, stackoverflow, google, bing and even yahoo forums without success. Every 10 seconds, I try to load text data from the logservlet servlet using 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 that on the server side I do not see a valid session where I am trying to track session attributes. The problem seems to be due to the lack of "Cookie JSESSIONID = xxxxxxxxxxxxxxxxxxxxxxxxxxx" in the header of the JQuery HTTP requests. I get response headers from the server, with the JSESSIONID always changing with every 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 afterwards, 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/

? "$.ajax" ? - JSESSIONID ajax? , ? , URL- -, JSESSIONID !

, .

+5
2

, Adblock Plus ( ), . . , , .

№1: - JSESSIONID :

    var Session = {
       id : '${pageContext.session.id}',
       user : '${pageContext.request.remoteUser}'
    };

    $(window).load(function () {
        setCookie('JSESSIONID',Session.id);
    });

    function setCookie(name,value,expires,path,domain,secure) {
        var cookieString = name + "=" +escape(value) +
           ( (expires) ? ";expires=" + expires.toGMTString() : "") +
           ( (path) ? ";path=" + path : "") +
           ( (domain) ? ";domain=" + domain : "") +
           ( (secure) ? ";secure" : "");
        document.cookie = cookieString;
    }

, JSESSIONID ajax .

№2: - mime / doGet() . . , , JQuery XML , doGet() , :

resp.setContentType( "/" );

ajax , cookie . , № 2 , .

, .

+2

, . cookie XHR.

0

All Articles