I need to pass a Java variable to a JavaScript function and I need to store that Java variable in JavaScript. What should I do?
Consider this Java code:
NodeList list = rootElement_plutus.getElementsByTagName("StatusMessage");
if (list != null && list.getLength() > 0)
{
NodeList subList = list.item(0).getChildNodes();
if (subList != null && subList.getLength() > 0)
{
STATUS_Plutus = subList.item(0).getNodeValue();
System.out.println("output: "+STATUS_Plutus);
"Here i need to pass variable 'STATUS_Plutus' to javascript function"
}
}
I am not using any servlets here. its just a normal fn.
Can u please give exact line so that I can paste it over there…
Javascript function is on the another page…
I am not exactly sure what you are trying to do, but you could try something like this (since you are alluding to passing DIRECTLY from Java to Javascript) … (only applies to JDK1.6+) …
p.s. Make sure you have previously imported these..