Need help to display a confirmation message after the form submission

I am submitting a form. I am calling a servlet for from submission. If the form submission is successful I want to show up a confirmation message in the form itself. Can someone help me how to do that.