[code ]
pessoal o problema e o seguinte tenho um servlet que envia os dados para uma jsp chamado de map.jsp, so que nao aparece nada na tela fica em branco
esse e o servlet q envia os parametros para o map.jsp
public class LocatorServlet extends HttpServlet {
private XStream xstream;
private LocationDAO dao;
public LocatorServlet() {
xstream = new XStream(new DomDriver());
xstream.alias("location", LocationVO.class);
dao = LocationDAO.getInstance();
}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
ArrayList locations = (ArrayList) dao.getAll();
req.setAttribute("locations", locations);
if(locations.size() > 0) {
req.setAttribute("lastLoc", locations.get(locations.size()-1));
}
req.getRequestDispatcher("map.jsp").forward(req, resp);
} catch (SQLException ex) {
ex.printStackTrace();
}
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
ServletInputStream in = req.getInputStream();
LocationVO loc = (LocationVO) xstream.fromXML(in);
try {
dao.insert(loc);
} catch (SQLException ex) {
ex.printStackTrace();
}
in.close();
}
}
esse e o map.jsp
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Web Mobile Locator</title>
<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2.x&sensor=false&key=ABQIAAAADsI1kshrwbEc63h9XALA8xRI2Lv0hn1zoIQYoZ4fHtTp-iEgnBTmUlaGu0g5PVY98q87FLlzJnlsUg"></script>
<script type="text/javascript">
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(${requestScope.lastLoc.latitude}, ${requestScope.lastLoc.longitude}), 13);
map.setUIToDefault();
var point, marker;
function createMarker(point, cardinalPoint, altitude, speed, timestamp) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml("<b>Direção:</b> "+cardinalPoint+"<br/><b>Altitude:</b> "+altitude+"<br/><b>Velocidade:</b> "+speed+"<br/><b>Estive aqui às:</b> "+timestamp);
});
return marker;
}
<c:forEach items="${requestScope.locations}" var="loc">
point = new GLatLng(${loc.latitude},${loc.longitude});
marker = createMarker(point, "${loc.courseDirection}", "${loc.altitude}", "${loc.speed}", "<fmt:formatDate type="both" pattern="HH:mm:ss dd/MM/yyyy" value="${loc.timestamp}" />");
map.addOverlay(marker);
</c:forEach>
var polyline = new GPolyline([
<c:forEach items="${requestScope.locations}" var="loc">
new GLatLng(${loc.latitude}, ${loc.longitude}),
</c:forEach>
], "#ff0000", 10);
map.addOverlay(polyline);
}
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
<div id="map" style="width: 600px; height: 400px"></div>
</body>
[/code ]
eu acho que o essro encontrase no seguinte trecho mais eu nao conheço nada de JSTL
var polyline = new GPolyline([
<c:forEach items="${requestScope.locations}" var="loc">
new GLatLng(${loc.latitude}, ${loc.longitude}),
</c:forEach>
], "#ff0000", 10);
map.addOverlay(polyline);
quem poder ajudar e quiser saber detalhes do cod e so da uma olhada na devmedia la tem todo os detalhes sobre o cod
agradeço a todos
[/code ]