I have a form on a JSP that sometimes takes a few seconds to save data to the database. If the user clicks the button a second time bad things can happen. How can I disable the button after it is first clicked until the form action is complete?
Your web app should be written to handle such situations, but it's also a good idea to disallow the user from getting themselves into trouble in the first place.
To disable a button simply set its disabled property to true.
It looks like you're using Struts which, I believe, has a built in mechanism for implementing the Synchronizer Token pattern which is also a way to avoid the double submit problem.