Ah, I see. You are making a common mistake, namely you think that the HTML scriptlet is repeatedly evaluated in the browser. That isn't the case -- your JSP runs on the server and generates HTML (including Javascript) which is interpreted by the browser. If you use the "Display Source" feature in your browser you'll see that this is the case.
But for a better explanation, read
The Secret Life of JavaServer Pages.
And yes, to do what you want to do you are going to have to use Ajax. However asking for random fragments of Ajax to be posted isn't going to be very useful, you're going to have to spend some time learning about it. Snippets aren't the way to go.