Problem in saving the form using java agent in the web browser

I have a few text fields in the form.I try to save the form while running it in a web browser.I am trying to save the values using a java agent by the doc.save,but it is not saving?Can anybody tell me how to save a document using java agent