priya priya - 5 months ago 14
Java Question

How to clear the form after submitting the values?

I have a form with few filed. Once i submit the form the data is stored in database and i will return to the same page.
Now, How to clear the fields in the form??

It is a struts based application. On submit it does some validations using java script then forwarded to the same page. Now, I must get a fresh page. I mean the fields must be cleared.

Answer

You can override Struts' Action reset() method and after you used it in your action you can do form.reset(request, response); and do a forward. That way, your form is resetted.

Comments