You're confusing your Java code (in the JSP) and your JavaScript code. The Java code runs on the server-side, before anything is returned to the browser, and has nothing to do with the JavaScript code. The JavaScript runs on the client-side, in the user's browser, after the Java code has already run.
What you're trying to do - which won't work - is use a JavaScript parameter inside your Java code. Since the Java has already executed, that makes absolutely no sense.
Your best bet would be to print out the Java array as a valid JavaScript array (saving it to a JavaScript variable), then use that in your JavaScript code. Something like this:
var javascriptArrayMenuNames = <%= Java code to output JSON representation of the array %>;
function setMainMenuUrl(index) {
document.getElementById('SelectedURL').value = javascriptArrayMenuNames[index];
}