Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Whats wrong with my JSP?

Posted on 2010-08-24
8
Medium Priority
?
627 Views
Last Modified: 2012-05-10
I am trying to use Google Maps Javascript API V3 with my JSP. Now the problem I am having is that

<%=Latitude%>,<%Longitude%> seems to cause an error im my JSP.

I want to create marker for each entry in the Vector, so as the for loop, loopsI want a create a marker on my map. How can I do this?

I have attached my JSP so far.

I dont know javascript so this is proving tricky.
0
Comment
Question by:bhession
8 Comments
 

Author Comment

by:bhession
ID: 33512444
Sorry here is the .jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title>Test</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
  html { height: 100% }
  body { height: 100%; margin: 0px; padding: 0px }
  #map_canvas { height: 100% }
</style>
<script type="text/javascript"
    src="http://maps.google.com/maps/api/js?sensor=false">
</script>
<script type="text/javascript">
  function initialize() {
    var latlng = new google.maps.LatLng(53.3, 8.9);
    var myOptions = {
      zoom: 7,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);

  
  }

</script>
</head>
<body onload="initialize()">
<%@ page import="com.google.project.Turbine" %>
<%@ page import="java.util.Vector" %>

<%
Vector<Turbine> turbines = new Vector<Turbine>();
turbines=(Vector<Turbine>)request.getAttribute("turbines");


if (turbines.size()==0){
	System.out.println("No record found matching your search"+"\n");
}
else if(turbines.size()!=0)
	{
for (int i=0; i < turbines.size(); i++)
{
	Turbine turbine = (Turbine)turbines.elementAt(i);

int ID = turbine.getID();
String TurbineSerialNo  = turbine.getTurbineSerialNo();
String ModelNumber = turbine.getModelNumber();
String ControllerSerialNo = turbine.getControllerSerialNo();
String MobileNo = turbine.getMobileNo();
String IMEINo = turbine.getIMEINo();
String AlternatorBNo = turbine.getAlternatorBNo();
String AlternatorCNo = turbine.getAlternatorCNo();
int Owner = turbine.getOwner();
String Address1 = turbine.getAddress1();
String Address2 = turbine.getAddress2();
String Address3 = turbine.getAddress3();
String County = turbine.getCounty();
String Country = turbine.getCountry();
String Northings = turbine.getNorthings();
String Eastings = turbine.getEastings();

double Latitude = Double.parseDouble(Northings);
double Longitude = Double.parseDouble(Eastings);

/*
out.println("<h4><br><b>ID is </b>"+ID
	    +"<br><b>TurbineSerialNo: </b>"+TurbineSerialNo
	    +"<br><b>Model No: </b>"+ModelNumber
	    +"<br><b>Controller Serial No: </b>"+ControllerSerialNo
	    +"<br><b>Mobile No: </b>"+MobileNo
	    +"<br><b>IMEI No: </b>"+IMEINo
	    +"<br><b>Alternator B No: </b+>"+AlternatorBNo
	    +"<BR><B>Alternator C No: </B>"+AlternatorCNo
	    +"<BR><B>Owner: </B>"+Owner
	    +"<BR><B>Address: </B>"+Address1+","+Address2+","+Address3+","+County+","+Country
	    +"<BR><B>Latitude: </B>"+Northings
	    +"<BR><B>Longitude: </B>"+Eastings);*/
	    

}
out.println("</h4>");

}
%>


  <div id="map_canvas" style="width:100%; height:100%"></div>
  <script type="text/javascript">
  var latlng2 = new google.maps.LatLng(<%=Latitude%>,<%=Longitude%>);
  var marker = new google.maps.Marker({
        position: myLatlng2, 
        map: map,
        title:"Hello World!"
    });   

</script>
  


  </body>
</html>

Open in new window

0
 
LVL 20

Accepted Solution

by:
chaitu chaitu earned 1000 total points
ID: 33512573
did u printed Latitude in scriplet whether value is coming or not??
try single quote

 var latlng2 = new google.maps.LatLng('<%=Latitude%>','<%=Longitude%>');
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 33512575
<%Longitude;%>
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 33512601

('<%=Latitude%>','<%=Longitude%>');  
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 33512615
Sorry chaituu: i didnt see ur code
0
 

Author Comment

by:bhession
ID: 33518682
Sorry guys that didnt seem to work either
0
 
LVL 11

Assisted Solution

by:Manish
Manish earned 1000 total points
ID: 33518889
This
var latlng2 = new google.maps.LatLng(<%=Latitude%>,<%=Longitude%>);
is outside of for loop. Put inside or make Latitude outside of for loop.
0
 

Author Closing Comment

by:bhession
ID: 34135007
I thought this was closed off, my apologies. The above lead to the solution.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question