j is just a string and your only choice is to send it to the server side
like so.
<form name="foo" method="post">
<input type="hidden" name="var_j">
<input type="submit">
<script>document.var_j = j</script>
After submitting the form you can assign it on the server side.
<% String s = request.getParameter("var_j")%>