>Is the correct way?
Well it could work...
>if yes then how should i pass control to javascript
You don't exactly pass control to javascript.
You generate javascript code to be run later.
The process of things
1 - The
JSP runs on the server and generates an HTML page with javascript
2 - The html/javascript runs in the browser.
So the question isn't how do you pass control to javascript.
It should be "Where is the best place to generate javascript code to do this"
The a function called by the onLoad event is a good place...
<script>
function runOnLoad(){
<c:if test="${randomTest == true}>
document.forms[0].description.value = 'This javascript is only generated if the
test condition is true';
</c:if>
}
</script>