I have a botton below named Button1 and a JSP method named method1. I want to be to execute method1 whenever someone clicks on Button1, but I do not know how. If there is a way this can be done please let me know. Any help is greatly appreciated. Thanks...
In the first request getParameter("Button1") returns null so the code in the "if" block is ingored.
When you click on the button, the form is submitted back to the server. This time getParameter("Button1") will return "Submit". Since the return value is not null, the code in the "if" block is executed.
NOTE: Putting the logic right in the JSP is called Model1 web programming and is highly discouraged these days. Once you get a grip on the whole request/response nature of web programming, you might want to look into model2 or the MVC architecture.