Accessing javascript variable in jsp in java -


i have included javascript file in head of jsp file! want there variable increasing using click on map, , want value in jsp page. please tell me how that, here code!

the jsp file code! incremental value defined clickhandler.js

<%@ 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> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>insert title here</title> <script src="http://www.openlayers.org/api/openlayers.js"></script> <script src="clickhandler.js" type="text/javascript"> </script> </head>  <h1>this login page</h1>  <body onload='init();'>   <form action="hellowelcome" method="post"> <input type="text" name="username"> <input type="text" name="surname"> <input type="submit" value="submit"> <div id="map" style="height: 650px" ></div> </form>  </body> </html> 

here clickhandler.js file code!

var i=0;  var map,vectorlayer, selectedfeature;            var lat=33.7167;             var lon=73.0667;             var zoom=10;             var map;         var curpos = new array();         var position;              var fromprojection = new openlayers.projection("epsg:4326");   // transform wgs 1984             var toprojection   = new openlayers.projection("epsg:900913"); // spherical mercator projection              var cntrposition       = new openlayers.lonlat(lon, lat).transform( fromprojection, toprojection);          function init()         {                 map = new openlayers.map("map",{                             controls:                              [                                         new openlayers.control.panzoombar(),                                                     new openlayers.control.layerswitcher({}),                             new openlayers.control.permalink(),                             new openlayers.control.mouseposition({}),                             new openlayers.control.scaleline(),                             new openlayers.control.overviewmap(),                                     ]                               }                                 );                 var mapnik      = new openlayers.layer.osm("map");               map.addlayers([mapnik]);             //map.addlayer(mapnik);             map.setcenter(cntrposition, zoom);              //markers.addmarker(new openlayers.marker(cntrposition));              var click = new openlayers.control.click();             map.addcontrol(click);              click.activate(); };  openlayers.control.click = openlayers.class(openlayers.control, {                 defaulthandleroptions: {   'single': true,   'double': false,   'pixeltolerance': 0,   'stopsingle': false,   'stopdouble': false  },   initialize: function(options) {   this.handleroptions = openlayers.util.extend(    {}, this.defaulthandleroptions   );   openlayers.control.prototype.initialize.apply(    this, arguments   );   this.handler = new openlayers.handler.click(    this, {     'click': this.trigger    }, this.handleroptions   );  },   trigger: function(e) {   var lonlat = map.getlonlatfrompixel(e.xy);   lonlat1= new openlayers.lonlat(lonlat.lon,lonlat.lat).transform(toprojection,fromprojection);   var long_value=lonlat1.lon;   var lat_value=lonlat1.lat;   //action=""   i=i+1;   alert("ur coordinates ..."+i+" "+long_value + "  " +lat_value);    //<a href="login.jsp"><a>   //<link href="login.jsp" >  } }); 


Popular posts from this blog