Search code examples
google-mapsjspcoordinatesgoogle-latitude

Retrieve lat and long javascript


Basically I have an html page with a map where I find the latitude and the longitude that I want, and I have to send these coordinates to a jsp page, But when I press Send I get the errorjava.lang.NullPointerException at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1017) at java.lang.Double.parseDouble(Double.java:540). So:

-in html I have

...<form action="GET.jsp" method="post" id="form" name="formMaps">
    <div id="map" style="float:left; width:100%; height:350px; margin-bottom:30px;"></div>
    Latitude <input type="String" name="lat" value="44.689205" id="coord_lat">
    <span style="margin-left:10px;">Longitude <input type="String" name="lon" value="10.663778" id="coord_lng"></span>
 <div align="center">        <input name="submit" type="submit" id="submit" value="SEND"  /> </div></form>...
  • in GET.JSP I have ...<% Double lati = Double.parseDouble(request.getParameter("lat")); Double longi = Double.parseDouble(request.getParameter("lon")); %>...

Solution

  • I think you should use input type text in your HTML code.

    <input type="String" name="lat" value="44.689205" id="coord_lat">
    

    replace this with

    <input type="text" name="lat" value="44.689205" id="coord_lat">