0

My jsp code and js code are within the same jsp file. I want to send two array to js part. Here is my jsp array:

String[] node = call.getAll(results_list[i * 18 + 1]);
int[] edge = call.getAllTable2();

Some websites said that I have to receive array at js part like below:

var node1 = <%=node%>;
var edge1 = <%=edge%>;

But this method could not work. It could only work well on string or int. Is there other method to pass my array?

Nikolas Charalambidis
  • 40,893
  • 16
  • 117
  • 183
Ma Hans
  • 11
  • 1

1 Answers1

0
Try Like this:

<script language="JavaScript">  

var node1= new Array();  
<%  
for (int i=0; i < node .length; i++) {  
%>  
node1[<%= i %>] = '<%=node [i] %>';
<%}%> 
</script>
Abu Sufian
  • 991
  • 1
  • 6
  • 15