0
What am I doing wrong? Why is the.log console not working when I enter the variable via JSP? The following error appears:
index.jsp:1 Uncaught Syntaxerror: Missing ) after argument list
at eval (<anonymous>) at jquery-1.7.2.min.js:2
Follow the code below:
<select id="cargo" name="cargo">
    <option value=""></option>                                                            
    <% 
       List<String> cargos = FuncApp.obterCargos();
       String sListaCargo;
       for(int i = 0; i < cargos.size(); i++) {
           sListaCargo = cargos.get(i);
    %>
    <script>
        console.log("sListaCargo:" + <%= sListaCargo %> );
    </script>
    <option value='<%= sListaCargo %>' <%= (sCargo.equals(sListaCargo)) ? "selected='selected'" : "" %>> <%= sListaCargo %> </option>                                                                
    <% 
       } //fecha for
    %>        
</select>
Related: How to pass the value of one variable in JSP to another in Javascript?
– Renan Gomes