title: How to get session variable on ajax success
body: <p>I have set session variable in my service implementation on LOG IN button click. And want to redirect on different page according to data returned and want to use different session variables on different pages .
  but unable to use it . this code has written in login page from where i want to redirect.</p>
  
  <pre><code>$(function() {
      $("#loginButton").click(function(event) {
          event.preventDefault();
          $.ajax({
              type : "POST",
              url : "http://localhost:9090/login",
              data : {
                  username : $("#user").val(),
                  password : $("#pass").val()
              },
              success : function(data) {
                  console.log(data);
                  if(data) {
                      var path="${pageContext.request.contextPath}";
                      /* alert(path); */
                      var user="&lt;%=session.getAttribute("Username")%&gt;"; 
                      $(location).attr("href",path.concat("/performance/performanceprofit.jsp"));
                  }
                  else {
                      $("#error").text("Invalid Username or Password");
                  }
              }
          })
      });
  });
  
  $(document).ready(function() {
      $("#error").empty();
  });
  </code></pre>