0
<select name="DB">
<option value="findmaximum" onclick="functionse()" style=font-size:20px>findmaximum</option>
<option value="marklist" onclick="functionse()"style=font-size:20px>marklist</option>
</select>

<script type="text/javascript">

function functionse(){
    var DBname=document.getElementsByName('DB');
    
    <%
        String DBname = (String) request.getAttribute("DB");
                System.out.println(DBname);
                ResultSet resultsettable=DBconnector.tables(DBname);
               String Tablenames[]=new String[0];
        int i=0;
    while(resultsettable.next()){
       String Tablename=resultsettable.getString("TABLE_NAME");
        Tablenames[i++]=Tablename;
        }

       %>
}

print DBname vaule but return null

Jens
  • 67,715
  • 15
  • 98
  • 113
  • Do not use db connections directly in a jsp – Jens Jan 26 '23 at 07:29
  • You can't access `DBname` in the scriptlet as they're executed at different times. The scriptlet is executed on the server, i.e. when the page is constructed, the JavaScript code runs in the browser, i.e. _after_ the page has been delivered. – Thomas Jan 26 '23 at 07:33
  • [What is the difference between client-side and server-side programming?](https://stackoverflow.com/q/13840429) – VLAZ Jan 26 '23 at 08:14

0 Answers0