-1

I have a class ManXML that has a method that returns an array of strings String[] : getArrayTemas(). I want to use that output as a variable in the script of my jsp.

 <script>
$(document).ready(function() {
    BindControls();
});

function BindControls() {
    const BD = new ManXML("BaseDados");

    var Temas = BD.getArrayTemas();

    $('#tbTemas').autocomplete({
        source : Temas,
        minLength : 0,
        scroll : true
    }).focus(function() {
        $(this).autocomplete("search", "");
    });
}
 </script>

1 Answers1

0

Yes, it's possible.
In my answer, I suppose your getArrayTemas() is a static method.

At first, you have to import your class in the jsp and then you can use your static method:

<%@page import="x.y.z.ManXML"%> 

<%
   String [] arrayTernas = ManXML.getArrayTemas();

%>

Finally you can use your arrayTernas with <%=arrayTernas%> or ${arrayTernas} (if you are using JSTL)

harry-potter
  • 1,981
  • 5
  • 29
  • 55