Here is my problem.

On my jsp, I have some java code.
When I get a certain exception in java, I want to display a confirm box to the user (currently using javascript). Based on what is returned from the user I want to perform an action using java.

I am thinking the code should look something like this:

<script type="text/javascript">
<!--
var answer = confirm ("Are you having fun?")
if (answer)
***PERFORM SOME JAVA CODE***
else
***PERFORM SOME JAVA CODE***
// -->
</script>

Is something like this possible? Can someone provide me with the correct syntax?
Thanks in advance