title: Google Maps JSP
body: <p>I am creating an application using the Google maps API and JSP.  I am having a problem because when I add an event to a marker and pass the value using a query string I am constantly getting the same value and not the actual value of the marker.  Could somebody please let me know what I am doing wrong?</p>
  
  <pre><code> &lt;%
  
              Query query2 = em.createNamedQuery("Factories.findAll");
              List&lt;Factories&gt; factories = query2.getResultList();
  
              for (int i = 0; i &lt; factories.size(); i++) {
                  Float longitude = factories.get(i).getLongitude();
                  Float latitude = factories.get(i).getLatitude();
                  String name = factories.get(i).getName();
                  Integer id = factories.get(i).getFactoryID();
          %&gt;
  
                  var marker = new google.maps.Marker({
                      position: new google.maps.LatLng(&lt;%=latitude%&gt;, &lt;%=longitude%&gt;),
                      raiseOnDrag:true,
                      title: "&lt;%=name%&gt;",
                      clickable:true,
                      zIndex: &lt;%=id%&gt;,
                      map: map
                  });
                  google.maps.event.addListener(marker, 'click', function() { 
                      window.location = "viewFireworksFactory.jsp?id=" + marker.getZIndex();
                  });
  
          &lt;% }%&gt;
  </code></pre>