title: Passing multiple values from Servlet to JSP but I get only 1 value in JSP
body: <p>I am trying to pass both latitude and longitude values from a Servlet to a JSP but I get only 1 value in the JSP</p>
  
  <p>Servlet page</p>
  
  <pre><code>for(int i=0;i&lt;json.length();i++)
  {
      String lat=json.getJSONObject(i).get("lat").toString();
      String lon=json.getJSONObject(i).get("lon").toString();
      lats[i]=lat;
      lons[i]=lon;
      request.setAttribute("lats", lats[i]);
      request.setAttribute("lons", lons[i]);
  
      System.out.println(lats[i]+","+lons[i]);
  }
  </code></pre>
  
  <p>JSP page</p>
  
  <pre><code>var len=&lt;%=request.getAttribute("len")%&gt;;
  lats[0]=&lt;%=request.getAttribute("lats")%&gt;;
  &lt;% String[] lats=(String[]) request.getAttribute("lats");%&gt; 
  &lt;% String[] lons=(String[]) request.getAttribute("lons");%&gt;
  
  for(i=0;i&lt;len;i++)
  {    
      var locations =[
                         ['&lt;%=request.getAttribute("cid")%&gt;',lats,lon]    
                     ];   
      alert(locations);  
  }
  </code></pre>
  
  <p>Where am I going wrong?</p>