title: passing value of arraylist to javascript
body: <p>I have the arraylist in one jsp.i want arraylist value in java script on another jsp.Can you please tell me how to do it.Following is my code.i have two jsp.</p>
  
  <p>getuser.jsp</p>
  
  <hr>
  
  <pre><code>Class.forName(driver).newInstance();
        conn = DriverManager.getConnection(url+dbName,userName,password);
              String query = "select user_registeration_code from system_user_master where user_first_name ='"+firstname+"' and user_last_name='"+lastname+"' and user_phone_no='"+emp_id+"'";
         st = conn.createStatement();
  
         ArrayList&lt;String&gt; addressLists1 = new ArrayList&lt;String&gt;();
             ResultSet  rs = st.executeQuery(query);
             while(rs.next())
                  {
  
  
                 addressLists1.add(rs.getString("user_registeration_code"));
  
  
                  }
                  out.println(addressLists1.size());
                  //out.println(data);
                  request.setAttribute("top", addressLists1);
  </code></pre>
  
  <p>second.jsp</p>
  
  <hr>
  
  <pre><code>&lt; script type = "text/javascript" &gt;
  
  
  function showEmp(emp_value) {
  
      var fname = document.getElementById("txtfirstname").value;
      alert(fname);
      var lname = document.getElementById("txtlastname").value;
      alert(lname);
      if (document.getElementById("txtmobileno").value != "") {
          alert("1");
          xmlHttp = GetXmlHttpObject();
          if (xmlHttp == null) {
              alert("2");
              alert("Browser does not support HTTP Request");
              return;
          }
          var url = "getuser.jsp";
          url = url + "?emp_id=" + emp_value + "&amp;firstname=" + fname + "&amp;lastname=" + lname;
  
          xmlHttp.onreadystatechange = stateChanged;
          xmlHttp.open("GET", url, true);
          xmlHttp.send(null);
  
      } else {
          alert("Please Select Employee Id");
      }
  }
  
  function stateChanged() {
      alert("3");
      document.getElementById("txtfirstname").value = "";
      document.getElementById("txtmobileno").value = "";
      if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
  
          alert("4");
          var showdata = [];
          showdata = xmlHttp.responseText;
          alert("qqqqqqqqq" + showdata.length);
          var i;
          for (i = 0; i &lt; showdata.length; i++) {
              alert("----------------" + showdata.get(i));
          }
      }
  }
  
  function GetXmlHttpObject() {
      var xmlHttp = null;
      try {
          // Firefox, Opera 8.0+, Safari
          xmlHttp = new XMLHttpRequest();
      } catch (e) {
          //Internet Explorer
          try {
              xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
          } catch (e) {
              xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
          }
      }
      return xmlHttp;
  }
  
  &lt; /script&gt;
  </code></pre>