If you are using
JSP, you might be able to do it with an expression. I did this once with ASP. For example, if your javascript code needs to use a JSP variable:
function myJsFunction () {
var jsVar = <%= jspVar %>;
}
The jspVar could be a value returned from a Java method. I haven't tried this in JSP, but it did work in ASP.