Anything within <% ... %> tags are parsed and
executed on the server while javascript runs on the
client machine. Now you could go the other way around
like this.
<% Integer testVar = new Integer( 1 ); %>
<script>
var test = <%= testVar.intValue() %>;
</script>
<% Vector myVector = new Vector();
myVector.addElements( testVar ) ; %>