My head is telling me that the answer to this question is going to be NO, but hopefully i m wrong.

I have a servlet which gets redirected using RequestDispatcher to a jsp page, the jsp page has some html input fields. In the servlet i get the values from the db and can place them in a json object, and want to display those values inside the input fields. I have a javascript function that can do that by looping through a jsonObject.

The question is this, can i fire a javascript function from the servlet?

Thanx am having a look at it right now, i just fear having to write a whole lot of setter and getter methods, so i hope that this will work in my app.

It seems the java scripting might not help, since from what i understand it is meant to use a javascript function inside the jvm, while i need to access it from servlet in a web browser. I could have understood it wrong though, if i m wrong please let me know.

No, you understood it right, and that's what I thought, you wanted, from the server, to use code on the client, when the client wouldn't even have it until the server is finished, since that is when the server would deliver that code to the client.

So, how did you want to do it now?

Then again, your JSP can set the onLoad attribute of the body tag to execute the JavaScript method as soon as the page is loaded.

cannot use the body onload since i am using all this inside an ajax based app.

its looking more like i will have to start typing those setter and getter methods :(

I couldnt find a way to do it, so went with teh setter and getter methods.