Solved

Whats wrong with my JSP?

Posted on 2010-08-24
8
625 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 250 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 250 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

634 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