title: how to pass form values from javascript to jsp page
body: <p>This is my sample html page which contains inline javascript which calculates the geocode and tries to return the latitude and longitude .But my question is how to submit all the form values with latitude and longitude returned from showlocation function to submitform.jsp page and display latitude value in jsp page .</p>
  
  <p>Index.html</p>
  
  <pre><code>    &lt;html&gt;
      &lt;head&gt;
  &lt;script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA5yM-fP6TPUheIXxW3TxpVRRgJAR_YXLeqIBw9Qs7Dzlh-4wFexRUVFiN8RbSageQjhAggT3jom"
      type="text/javascript"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"
      src="http://maps.google.com/maps/api/js?sensor=false"&gt;
  &lt;/script&gt;
  
      &lt;script type="text/javascript"&gt;
      geocoder = new GClientGeocoder();
       function showlocation() {
              var clientaddress = document.getElementById('addstreetname').value;
              geocoder.getLocations(clientaddress, function(response) {
                  if (!response || response.Status.code != 200) {
                      alert("Sorry, we were unable to geocode the first address");
  
                  }
                  else {
                      var lat1 = response.Placemark[0].Point.coordinates[1];
                      var lng1 = response.Placemark[0].Point.coordinates[0];
  
                      return {latitude: lat1, longitude: lng1};
          }
              });
      &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
      &lt;form id="addresslistingform" action="submitform.jsp" onsubmit="returnshowlocation();"&gt;
                  Company_Name:&lt;br/&gt;
                        &lt;input size="30" type="text" id="businessname" name="businessname"/&gt;&lt;br/&gt;
                      Zipcode:&lt;br/&gt;
                        &lt;input size="30" type="text" id="zipcode"  name="zipcode1"/&gt;&lt;br/&gt;
                      Street No:&lt;br/&gt;
                        &lt;input size="30" type="text" id="addstreetno" name="streetno"/&gt;&lt;br/&gt;
                      Street Name:&lt;br/&gt; 
                        &lt;input size="30" type="text" id="addstreetname"  name="streetname"/&gt;&lt;br/&gt;
                      State:&lt;br/&gt;                  
                        &lt;select name="select2" id="select2" class="required" name="state" &gt;
                          &lt;option value=""&gt;Select Your State&lt;/option&gt;
                          &lt;option value="1"&gt; karnataka&lt;/option&gt;
                          &lt;option value="2"&gt; Kerala&lt;/option&gt;
                         &lt;option value="3"&gt; Andhra Pradesh&lt;/option&gt;
                         &lt;/select&gt;
      &lt;/form&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>submitform.jsp</p>
  
  <pre><code>&lt;%@ page language="java" import="java.sql.*" %&gt;
  
       &lt;%
              String driver = "com.mysql.jdbc.Driver";
                  Class.forName(driver).newInstance();
              Connection con=null;
              ResultSet rst=null;
              Statement stmt=null;
  
          try{
              String url = "jdbc:mysql://localhost:3306/";
                  String dbName = "db";
                  String driverName = "com.mysql.jdbc.Driver";
                  String userName = "";
                  String password = "";
  
  
              con = DriverManager.getConnection(url+dbName, userName, password);
              stmt=con.createStatement();
          }catch(Exception e){
                  System.out.println(e.getMessage());
                }
  
  
       String Company_Name=request.getParameter("businessname");
       String Zipcode =request.getParameter("zipcode1");
      String Street_Number=request.getParameter("streetno");
      String Street_Name=request.getParameter("streetname");
      String State= request.getParameter("state");    
     String Latitude=request.getParameter("Latitude");
      out.println("latitude is :"+request.getParameter("Latitude"));
  
            %&gt;
  </code></pre>