Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Javascript not detecting argument passed by JSP code

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

So I am developing a JSP powered application. I've only included some portion of my code. Basically the javascript file reads an XML document that has the latitude/longitude coordinates of some highway, depending upon the traffic congestion a portion of the road will have a Polyline on it (I am using Google Maps to map the polylines onto the highway).

The JS file itself does the job (Only the function of concern has been posted), however this portion of the code is static (the other part is of course dynamic.) Anyway to the point now I wish to pass a certain colour value to the function "function processPolyLines()". Depending upon this colour value a certain portion of the highway will be illuminated.

the JS file (Traffic.js):

So now I have this basic JSP file (TrafficRequest.jsp):

To access the Javascript file's variables I am doing it via JSP. I've assigned the variable "colour" to red. And when this JSP file is run it will pass this value to the JS function as shown.

My problem being that regardless of whatever colour value I pass the highway (on google maps) is not covered with the polyline of the colour I want (otherwise it shows no polyline or an unexpected colour). If I disregard the JSP file by not passing a colour value to the function in the javascript file and uncommenting the line that reads the "colour attribute" tag (3rd line down from getElementsByTagName) on the XML file it displays the polylines with their hardcoded colour values just fine.

So can anyone please help? Thanks!

PS: The main page is Traffic.jsp which is what the user will open to access the congestion information, I've included a small portion of it below to show how I am calling the Traffic.js file:


PS2: So what have I tried?

The above does not work.

But if I pass the colour value in the javascript file directly it shows the colour I want. Example:
Posts: 67300
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the JavaScript code look right when it gets to the browser? If so, the problem is not in JSP. If not, then it is.

Which is it?
Don't MAKE me come back there with this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!