0

I'm developing a webapp with Spring MVC and I'm in front of a problem. I'm performing an HTTP request to my webapp server using Ajax, and so far everything works fine. The problem comes when I start using the session... in particular each time I try to query the session (from the server side) it seems that it's always a new one, it doesn't contain any attributes I stored before. This is the way in which I perform the Ajax call:

function methodName(message){
        var url = SERVICE_ADDRESS + ":" + SERVICE_PORT + "/path";
        $.ajax( {
            type: "POST",
            url: url,
            data: JSON.stringify(message),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            cache: false,
            success : function(data) {
                //DOING STUFF
            },
            error : function(e) {
                //DOING STUFF
            }
        });
    }

Perhaps I'm missing something inside the body of my Ajax call. From the backend side I'm just retrieving the session through the object HttpServletRequest as I've always done. The only difference between what I've always done and this, is Ajax... usually I'm calling an HTTP request using the Spring form, so either Ajax doesn't support sessions or I'm missing something inside the call. Is there someone who could help me? Thank you very very very much

Stefano Sambruna
  • 617
  • 1
  • 9
  • 20

0 Answers0