title: Getting Session data in Ajax call
body: <p>hi I am querying database to load all items based on some criteria and setting this result in session as </p>
  
  <pre><code>data = service.getData();
  session.setAttribute("data", data);
  </code></pre>
  
  <p>now I am trying to access this data via an Ajax call and my Ajax call is served by a different servlet rather then which fetched the data from DB. </p>
  
  <p>Ajax call using jquery </p>
  
  <pre><code>$.ajax({
      type: "POST",
      url: "/com/tp/AjaxXML.jsp",
      data: ({cmd: "report"}),
      dataType: "xml",
      success: function(xml) {
          $(xml).find('site').each(function(){
              var url = $(this).attr('url');                                  
          });
      }
  });
  </code></pre>
  
  <p>in my AjaxXML.jsp </p>
  
  <p>I am doing </p>
  
  <pre><code>if("report".equals(cmd)){
      List&lt;Object&gt; data = (List&lt;Object&gt;)request.getSession().getAttribute("data");
  
      if(data == null){
          System.out.println("data is null ");
      }
  }
  </code></pre>
  
  <p>every time I am getting the data as null via the Ajax call how ever I try to access the session data normally from my first servlet it works. </p>
  
  <p>could someone let me know if I am doing something wrong?</p>
  
  <p>I noticed one more thing when we do <code>session.getId();</code> and <code>pageContext.getSession().getId();</code>
  both of them are returning different Id's? Is this expected to me they should be same anyone differ on that?</p>